next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Graphs :: graph

graph -- The function that creates a graph.

Synopsis

Description

The graph is stored as a hash table whose keys are the nodes and whose values are the neighbors of the nodes. The user inputs a graph by inputting a list of edges. There is an optional argument called Singletons to input nodes that have no neighbors.
i1 : A = graph({{x_1,x_3},{x_2,x_4},{x_1,x_4}})

o1 = Graph{x  => set {x , x }}
            1          3   4
           x  => set {x }
            2          4
           x  => set {x }
            3          1
           x  => set {x , x }
            4          1   2

o1 : Graph
i2 : B = graph({{a,b},{c,d},{a,d},{b,c}}, Singletons => {f})

o2 = Graph{a => set {b, d}}
           b => set {a, c}
           c => set {b, d}
           d => set {a, c}
           f => set {}

o2 : Graph
Alternatively, one can also create a graph by inputting a hash table whose keys are again the nodes of the graph and the values the neighbors of the nodes.

Ways to use graph :