IsDirected - Maple Help

GraphTheory

 IsDirected
 test if graph is directed
 IsWeighted
 test if graph is weighted

 Calling Sequence IsDirected(G) IsWeighted(G)

Parameters

 G - graph

Description

 • The IsDirected(G) function returns true or false depending on whether the input graph is a directed or undirected graph.
 • The IsWeighted(G) function returns true if G is a weighted graph, and false otherwise.
 • To make a graph directed or weighted, use the MakeDirected or MakeWeighted commands.
 • To remove directions and weights from a graph, use the UnderlyingGraph command.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left\{\left[1,2\right],\left[2,3\right],\left[3,1\right]\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: a directed unweighted graph with 3 vertices and 3 arc\left(s\right)}}$ (1)
 > $\mathrm{IsDirected}\left(G\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{IsWeighted}\left(G\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{DrawGraph}\left(G\right)$
 > $\mathrm{K3}≔\mathrm{CompleteGraph}\left(3\right)$
 ${\mathrm{K3}}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 3 vertices and 3 edge\left(s\right)}}$ (4)
 > $\mathrm{IsDirected}\left(\mathrm{K3}\right)$
 ${\mathrm{false}}$ (5)
 > $H≔\mathrm{Graph}\left(\left\{\left[\left\{1,2\right\},2\right],\left[\left\{2,3\right\},3\right]\right\}\right)$
 ${H}{≔}{\mathrm{Graph 3: an undirected weighted graph with 3 vertices and 2 edge\left(s\right)}}$ (6)
 > $\mathrm{IsWeighted}\left(H\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{WeightMatrix}\left(H\right)$
 $\left[\begin{array}{ccc}{0}& {2}& {0}\\ {2}& {0}& {3}\\ {0}& {3}& {0}\end{array}\right]$ (8)
 > $\mathrm{K3}≔\mathrm{CompleteGraph}\left(3\right)$
 ${\mathrm{K3}}{≔}{\mathrm{Graph 4: an undirected unweighted graph with 3 vertices and 3 edge\left(s\right)}}$ (9)
 > $\mathrm{IsWeighted}\left(\mathrm{K3}\right)$
 ${\mathrm{false}}$ (10)
 > $\mathrm{K3}≔\mathrm{MakeWeighted}\left(\mathrm{K3}\right)$
 ${\mathrm{K3}}{≔}{\mathrm{Graph 5: an undirected weighted graph with 3 vertices and 3 edge\left(s\right)}}$ (11)
 > $\mathrm{IsWeighted}\left(\mathrm{K3}\right)$
 ${\mathrm{true}}$ (12)
 > $\mathrm{WeightMatrix}\left(\mathrm{K3}\right)$
 $\left[\begin{array}{ccc}{0}& {1}& {1}\\ {1}& {0}& {1}\\ {1}& {1}& {0}\end{array}\right]$ (13)