Main Content

Graph with undirected edges

`graph`

objects represent undirected graphs, which have
direction-less edges connecting the nodes. After you create a graph object, you can
learn more about the graph by using 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 = graph([1 1], [2 3]); e = G.Edges G = addedge(G,2,3) G = addnode(G,4) plot(G)

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

= graph(`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 between node
2 and node 1 with a weight of 10.

specifies graph edges `G`

= graph(`s,t`

)`(s,t)`

in node pairs.
`s`

and `t`

can specify node indices
or node names. `graph`

sorts the edges in
`G`

first by source node, and then by target node. If
you have edge properties that are in the same order as `s`

and `t`

, use the syntax ```
G =
graph(s,t,EdgeTable)
```

to pass in the edge properties so that
they are sorted in the same manner in the resulting graph.