Macaulay2 » Documentation
Packages » Graphs :: digraph
next | previous | forward | backward | up | index | toc

# digraph -- Constructs a digraph

- Usage:
    `G = digraph E`
    `G = digraph H`
    `G = digraph (V, E)`
    `G = digraph (V, A)`
    `G = digraph A`
- Inputs:
  - E, a list, Denotes an edge list (a list of ordered pair lists)
  - V, a list, Denotes a vertex list
  - H, a hash table,
  - A, a matrix, Denotes an adjacency matrix
- Optional inputs:
  - EntryMode (missing documentation) => ..., default value "auto",
  - Singletons (missing documentation) => ..., default value null,
- Outputs:
  - G, a digraph,

## Description

A digraph is a set of vertices connected by directed edges. Unlike the case with simple graphs, {u,v} being an edge does not imply that {v,u} is also an edge. Notably, this allows for non-symmetric adjacency matrices.

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

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

    o1 : Digraph

    i2 : G = digraph hashTable{1 => {2}, 3 => {4}, 5 => {6}}

    o2 = Digraph{1 => {2}}
                 2 => {}
                 3 => {4}
                 4 => {}
                 5 => {6}
                 6 => {}

    o2 : Digraph

    i3 : G = digraph ({{a,{b,c,d,e}}, {b,{d,e}}, {e,{a}}}, EntryMode => "neighbors")

    o3 = Digraph{a => {e, b, c, d}}
                 b => {e, d}
                 c => {}
                 d => {}
                 e => {a}

    o3 : Digraph

    i4 : G = digraph ({x,y,z}, matrix {{0,1,1},{0,0,1},{0,1,0}})

    o4 = Digraph{x => {y, z}}
                 y => {z}
                 z => {y}

    o4 : Digraph

    i5 : G = digraph matrix {{0,1,1},{0,0,1},{0,1,0}}

    o5 = Digraph{0 => {1, 2}}
                 1 => {2}
                 2 => {1}

    o5 : Digraph

## See also

- graph -- Constructs a simple graph

## Ways to use digraph:

- `digraph(HashTable)`
- `digraph(List)`
- `digraph(List,List)`
- `digraph(List,Matrix)`
- `digraph(Matrix)`

## For the programmer

The object digraph is a method function with options.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Graphs.m2:1823:0.