Source and target node pairs, specified as scalars, vectors,
matrices, multidimensional arrays, character vectors, or cell arrays
of character vectors. digraph
creates directed
edges between the corresponding nodes in s
and t
,
which must both be numeric, or both be character vectors or cell arrays
of character vectors. In each case, s
and t
must
have the same number of elements.
If s
and t
are
numeric, then they correspond to indices of graph nodes. Numeric node
indices must be positive integers greater than or equal to 1.
If s
and t
are
character vectors or cell arrays of character vectors, then they specify
names for the nodes. The Nodes
property of the
graph is a table containing a Name
variable with
the node names, G.Nodes.Name
.
s
and t
cannot
specify duplicate edges. For directed graphs, digraph([1
2],[2 1])
specifies two unique edges, but digraph([1
1],[2 2])
specifies a duplicate edge with node 1 as the
source and node 2 as the target.
Example: G = digraph([1 2 3],[2 4 5])
creates
a graph with five nodes and three edges.
Example: G
= digraph({'Boston' 'New York' 'Washington D.C.'},{'New York' 'New
Jersey' 'Pittsburgh'})
creates a graph with five named nodes
and three edges.