PropertyValue

As of Version 12.1, PropertyValue has been superseded by AnnotationValue.

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:
  • 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.
  • 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 all

Basic Examples  (1)

Generate a complete graph with properties:

Retrieve the property value associated with a property name:

Change the property value:

Unset the property value:

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:

And edges:

PropertyValue returns $Failed for undefined properties:

Vertex Properties  (2)

Standard vertex properties include VertexStyle:

VertexLabels:

VertexSize:

VertexShape:

VertexShapeFunction:

Non-visual properties include VertexWeight:

Set a custom property:

Edge Properties  (2)

Standard edge properties include EdgeStyle:

EdgeLabels:

Non-visual properties include EdgeWeight:

Set a custom property:

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:

Create a weighted graph:

Set edge weights:

Compute weight scale:

Set the edge thickness to reflect the edge weight:

Highlight a path and mark the start point and endpoint:

Select vertices along a path:

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:

Do five updates a second:

Dynamically visualize breadth-first search:

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:

The original graph is unchanged:

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:

Wolfram Research (2010), PropertyValue, Wolfram Language function, https://reference.wolfram.com/language/ref/PropertyValue.html (updated 2015).

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

BibTeX

@misc{reference.wolfram_2024_propertyvalue, author="Wolfram Research", title="{PropertyValue}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/PropertyValue.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_propertyvalue, organization={Wolfram Research}, title={PropertyValue}, year={2015}, url={https://reference.wolfram.com/language/ref/PropertyValue.html}, note=[Accessed: 21-November-2024 ]}