Macaulay2 » Documentation
Packages » Graphs :: graph(Digraph)
next | previous | forward | backward | up | index | toc

graph(Digraph) -- Returns the legacy G#graph hash table



A graph consists of two sets, a vertex set and an edge set which is a subset of the collection of subsets of the vertex set. Edges in graphs are symmetric or two-way; if u and v are vertices then if {u,v} is an edge connecting them, {v,u} is also an edge (which is implicit in the definition, we will almost always just use one of the pairs). The options for EntryMode are "neighbors" (the default) and "edges". This method returns a hash table where the keys are vertices of a given graph or digraph and the values are their children (or neighbors, in the case of undirected graphs).

i1 : G = graph digraph({{1,2},{2,1},{3,1}}, EntryMode => "edges")

o1 = HashTable{1 => {2}}
               2 => {1}
               3 => {1}

o1 : HashTable
i2 : G = graph digraph(matrix {{0,1,1},{1,0,0},{1,0,0}})

o2 = HashTable{0 => {1, 2}}
               1 => {0}
               2 => {0}

o2 : HashTable

See also

Ways to use this method: