GraphTheory
IsDirected
test if graph is directed
IsWeighted
test if graph is weighted
Calling Sequence
Parameters
Description
Examples
IsDirected(G)
IsWeighted(G)
G
-
graph
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.
with⁡GraphTheory:
G≔Graph⁡1,2,2,3,3,1
G≔Graph 1: a directed graph with 3 vertices and 3 arc(s)
IsDirected⁡G
true
IsWeighted⁡G
false
DrawGraph⁡G
K3≔CompleteGraph⁡3
K3≔Graph 2: an undirected graph with 3 vertices and 3 edge(s)
IsDirected⁡K3
H≔Graph⁡1,2,2,2,3,3
H≔Graph 3: an undirected weighted graph with 3 vertices and 2 edge(s)
IsWeighted⁡H
WeightMatrix⁡H
020203030
K3≔Graph 4: an undirected graph with 3 vertices and 3 edge(s)
IsWeighted⁡K3
K3≔MakeWeighted⁡K3
K3≔Graph 5: an undirected weighted graph with 3 vertices and 3 edge(s)
WeightMatrix⁡K3
011101110
See Also
MakeDirected
MakeWeighted
UnderlyingGraph
WeightMatrix
Download Help Document