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 name1, name2, etc.
Details
- Properties are used to store and manipulate name->value pairs for specific named items within an object such as Graph, MeshRegion, and BoundaryMeshRegion.
- The item specification itemspec typically has the form {collection,index}.
- The index can typically have the following forms:
-
ind a single index {ind1,ind2,…} a list of indexes All all possible indexes in collection patt indexes that match patt in collection - The collection can typically have the following forms:
-
col a single collection {col1,col2,…} a list of collections All all possible collections patt collections 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.
- Objects that support properties include Graph, MeshRegion, and BoundaryMeshRegion. Item specifications for each type of object is given in their reference pages.
Examples
open allclose allBasic Examples (1)
Scope (8)
Basic Uses (4)
Set a property value for vertex 1:
Retrieve the property value for vertex 1:
Set a property value for the edge 12:
Retrieve the property value for the edge 12:
Unset properties for vertices:
PropertyValue returns $Failed for undefined properties:
Vertex Properties (2)
Standard vertex properties include VertexStyle:
Non-visual properties include VertexWeight:
Edge Properties (2)
Standard edge properties include EdgeStyle:
Non-visual properties include EdgeWeight:
Applications (5)
Use Do to set several property values:
Or different property values for different items:
Use Table to build a list of property values:
Set the edge thickness to reflect the edge weight:
Highlight a path and mark the start point and endpoint:
Highlight by setting edge style along the path and vertex labels for start point and endpoint:
Dynamically highlight the edges in the order given by EdgeList:
Properties & Relations (4)
Use Property as a wrapper to specify properties in functions such as Graph:
Use PropertyList to test for the presence of a property:
Generate a list of vertex label rules:
Use SetProperty to set a property without changing the original:
The original graph is unchanged:
Use RemoveProperty to remove a property without changing the original:
Possible Issues (3)
PropertyValue returns $Failed for undefined properties:
Use PropertyList to test for the presence of a property:
PropertyValue may return $Failed even when a property value exists:
Use PropertyList to check for actual property values:
PropertyValue returns the first value associated with a property for identical edges:
Text
Wolfram Research (2010), PropertyValue, Wolfram Language function, https://reference.wolfram.com/language/ref/PropertyValue.html (updated 2015).
CMS
Wolfram Language. 2010. "PropertyValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/PropertyValue.html.
APA
Wolfram Language. (2010). PropertyValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PropertyValue.html