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

## Synopsis

• Function: graph
• Usage:
G = graph D
• Inputs:
• D, an instance of the type Digraph,
• Optional inputs:
• EntryMode => ..., default value auto, Constructs a simple graph
• Singletons => ..., default value null, Constructs a simple graph
• Outputs:
• H, , The hash table with a graph's vertices as keys and list of neighbors as values.

## Description

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