You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/README.jl
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -37,19 +37,19 @@ has_vertex(g, "A")
37
37
has_edge(g, "A"=>"B")
38
38
has_edge(g, "A"=>"C")
39
39
neighbors(g, "B")
40
-
g[["A", "B"]]
40
+
subgraph(g, ["A", "B"])
41
41
42
42
#' Internally, this type wraps a `SimpleGraph`, and stores a `Dictionary` from the [Dictionaries.jl](https://github.com/andyferris/Dictionaries.jl) package that maps the vertex names to the linear indices of the underlying `SimpleGraph`.
43
43
44
44
#' Graph operations are implemented by mapping back and forth between the generalized named vertices and the linear index vertices of the `SimpleGraph`.
45
45
46
46
#' It is natural to use tuples of integers as the names for the vertices of graphs with grid connectivities.
47
-
#' For this, we use the convention that if a tuple is input, it is interpreted as the grid size and
48
-
#' the vertex names label cartesian coordinates:
47
+
#' For example:
49
48
#+ term=true
50
49
51
-
g =NamedGraph(grid((2, 2)); vertices=(2, 2))
50
+
g =NamedGraph(grid((2, 2)); vertices=Tuple.(CartesianIndices((2, 2))))
52
51
52
+
#' In the future we will provide a shorthand notation for this, such as `cartesian_graph(grid((2, 2)), (2, 2))`.
53
53
#' Internally the vertices are all stored as tuples with a label in each dimension.
54
54
55
55
#' Vertices can be referred to by their tuples:
@@ -65,9 +65,7 @@ neighbors(g, (2, 2))
65
65
66
66
subgraph(v -> v[1] ==1, g)
67
67
subgraph(v -> v[2] ==2, g)
68
-
g[[(1, 1), (2, 2)]]
69
-
70
-
#' Note that this is similar to multidimensional array slicing, and we may support syntax like `subgraph(v, 1, :)` in the future.
68
+
subgraph(g, [(1, 1), (2, 2)])
71
69
72
70
#' You can also take [disjoint unions](https://en.wikipedia.org/wiki/Disjoint_union) or concatenations of graphs:
0 commit comments