EdgeWeight

EdgeWeight
is an option and property for Graph and related functions that specifies an edge weight.

DetailsDetails

  • The following option settings can be used:
  • {w1,w2,...}give all edge weights in the same order as used by EdgeList
  • The wrapper Property[viUndirectedEdgevj, EdgeWeight->w] can be used when creating graphs in functions such as Graph etc.
  • The weight can be any expression.
  • The weight can be interpreted as cost or capacity, or can have other special meanings for different graph computation functions.

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

Set a weight for all edges:

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

Use any numeric expression as a weight:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//MatrixForm=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »