H = transclosure(G)
Create and plot a directed graph.
G = digraph([1 2 3 4 4 4 5 5 5 6 7 8],[2 3 5 1 3 6 6 7 8 9 9 9]); plot(G)
Find the transitive closure of graph
G and plot the resulting graph.
H contains the same nodes as
G, but has additional edges.
H = transclosure(G); plot(H)
The transitive closure information in
H can be used to answer reachability questions about the original graph,
Determine the nodes in
G that can be reached from node 1. These nodes are the successors of node 1 in the transitive closure graph,
N = successors(H,1)
N = 2 3 5 6 7 8 9
H— Transitive closure of
Transitive closure of
G, returned as a
digraph object. The table
is copied to
H, but any properties in
G.Edges are dropped.
successors(H,n) to determine the nodes in
G that are reachable from node
The transitive closure of a graph describes the paths between the
nodes. If there is a path from node
i to node
j in a graph, then an edge exists between node
i and node
j in the transitive closure of
that graph. Thus, for a given node in the graph, the transitive closure turns any
reachable node into a direct successor (descendent) of that node.