PropertyValue

PropertyValue[{obj,item},name]
gives the property value associated with name for item in obj.

PropertyValue[{obj,itemspec},name]
gives the property values associated with name for items indicated by itemspec in obj.

PropertyValue[,{name1,name2,}]
gives a list of property values associated with , , etc.

DetailsDetails

  • Properties are used to store and manipulate pairs for specific named items within an object such as Graph.
  • The item specification itemspec typically has the form .
  • The index can typically have the following forms:
  • inda single index
    {ind1,ind2,}a list of indexes
    Allall possible indexes in collection
    pattindexes that match patt in collection
  • The collection can typically have the following forms:
  • cola single collection
    {col1,col2,}a list of collections
    Allall possible collections
    pattcollections that match patt
  • The item specification itemspec of the form collection refers to the default value for all indexes in the collection.
  • PropertyValue[{obj,itemspec},name] returns $Failed whenever there is no property value available for name.
  • PropertyValue[{obj,itemspec},name]=val can be used to modify the property value.
  • The items available for Graph objects include vertices and edges.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Generate a complete graph with properties:

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

Retrieve the property value associated with property name:

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

Change the property value:

In[3]:=
Click for copyable input
In[4]:=
Click for copyable input
Out[4]=

Unset the property value:

In[5]:=
Click for copyable input
In[6]:=
Click for copyable input
Out[6]=
Introduced in 2010
(8.0)
| Updated in 2014
(10.0)