WeightedGraphQ

WeightedGraphQ[g]

yields True if the graph g is a weighted graph and False otherwise.

Details

  • WeightedGraphQ will give True if there is an explicit VertexWeight or EdgeWeight property defined.
  • In cases where a weighted graph is expected, the default vertex and edge weights are taken to be 1.
  • Weights are often taken to mean cost, capacity, etc.

Examples

open allclose all

Basic Examples  (2)

Test whether a graph is a weighted graph:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Test matrix graphs:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (4)

Possible Issues  (1)

See Also

VertexWeight  EdgeWeight  FindShortestPath

Introduced in 2010
(8.0)