SetProperty

As of Version 12.1, SetProperty has been superseded by Annotate.

SetProperty[{obj,itemspec},namevalue]

sets the property namevalue for itemspec in obj.

Details

  • Properties are used to store and manipulate name->value pairs for specific named items within an object such as Graph.
  • SetProperty will produce an object with a modified property value.
  • 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.
  • The items available for Graph objects include vertices and edges.

Examples

open allclose all

Basic Examples  (2)

Specify a vertex or edge property:

Use SetProperty to override the vertex style:

Scope  (6)

Basic Uses  (2)

Set properties for vertices:

And edges:

Set several properties for a vertex:

And for an edge:

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:

EdgeShapeFunction:

Non-visual properties include EdgeWeight:

Set a custom property:

Applications  (3)

Use Fold to apply SetProperty repeatedly:

See all the partial results:

Create a graph:

Temporarily highlight one vertex:

Then another:

Highlight the edges visited during a breadth-first scan:

Properties & Relations  (6)

Use Property as a wrapper to specify properties in functions such as Graph:

Use PropertyValue to extract values:

For undefined properties, the value $Failed is returned:

Use PropertyValue to set properties in a graph:

The original graph has changed:

Use PropertyValue to unset properties in a graph:

The original graph has changed:

Use PropertyList to test for the presence of a property:

Generate a list of vertex label rules:

Use RemoveProperty to remove a property without changing the original:

The original graph is unchanged:

Possible Issues  (1)

PropertyValue is typically faster than SetProperty:

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

Text

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

CMS

Wolfram Language. 2010. "SetProperty." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SetProperty.html.

APA

Wolfram Language. (2010). SetProperty. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SetProperty.html

BibTeX

@misc{reference.wolfram_2023_setproperty, author="Wolfram Research", title="{SetProperty}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/SetProperty.html}", note=[Accessed: 18-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_setproperty, organization={Wolfram Research}, title={SetProperty}, year={2010}, url={https://reference.wolfram.com/language/ref/SetProperty.html}, note=[Accessed: 18-March-2024 ]}