Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Graph with directed edges

`digraph`

objects represent directed graphs, which have
directional edges connecting the nodes. After you create a `digraph`

object, you can learn more about the graph by using the object functions to perform
queries against the object. For example, you can add or remove nodes or edges, determine
the shortest path between two nodes, or locate a specific node or edge.

G = digraph([1 1], [2 3]) e = G.Edges G = addedge(G,2,3) G = addnode(G,4) plot(G)

`G = digraph`

`G = digraph(A)`

`G = digraph(A,nodenames)`

`G = digraph(A,NodeTable)`

`G = digraph(A,___,'omitselfloops')`

`G = digraph(s,t)`

`G = digraph(s,t,weights)`

`G = digraph(s,t,weights,nodenames)`

`G = digraph(s,t,weights,NodeTable)`

`G = digraph(s,t,weights,num)`

`G = digraph(s,t,___,'omitselfloops')`

`G = digraph(s,t,EdgeTable,___)`

`G = digraph(EdgeTable)`

`G = digraph(EdgeTable,NodeTable)`

`G = digraph(EdgeTable,___,'omitselfloops')`

creates a weighted directed graph using a square adjacency matrix,
`G`

= digraph(`A`

)`A`

. The location of each nonzero entry in
`A`

specifies an edge for the graph, and the weight of
the edge is equal to the value of the entry. For example, if ```
A(2,1)
= 10
```

, then `G`

contains an edge from node 2
to node 1 with a weight of 10.