8
$\begingroup$

Graph objects can have different kinds of "properties":

  • vertex properties
  • edge properties
  • graph properties

Each of these can be standard ones, such as EdgeWeight, which are stored as options taking the values of a list. Or they can be custom properties, which are stored in the Properties option.

Example:

g = Graph[{1 <-> 2, 2 <-> 3}];

In[]:= SetProperty[{g, 1}, "shoo" -> 3] // InputForm
Out[]= Graph[{1, 2, 3}, {UndirectedEdge[1, 2], UndirectedEdge[2, 3]}, 
 {Properties -> {1 -> {"shoo" -> 3}}}]

In[]:= SetProperty[{g, 1}, VertexCapacity -> 3] // InputForm
Out[]= Graph[{1, 2, 3}, {UndirectedEdge[1, 2], UndirectedEdge[2, 3]}, 
 {VertexCapacity -> {3, 1, 1}}]

Notice that a custom property can be set for a single vertex only while a standard property is set for all vertices and takes a default value for vertices which were not specified.

I am looking for a full list of standard graph properties along with their default values (when there is one).

I need this to implement robust and easy to use property remapping.

$\endgroup$
0

1 Answer 1

7
$\begingroup$
Property name        Refers to       Stored as        Default
-------------------------------------------------------------

VertexWeight         vertices        list             1
VertexCapacity       vertices        list             1
VertexCoordinates    vertices        list             none (*)

VertexSize           vertices        rules
VertexShape          vertices        rules
VertexShapeFunction  vertices        rules
VertexStyle          vertices        rules
VertexLabels         vertices        rules
VertexLabelStyle     vertices        rules

EdgeWeight           edges           list             1
EdgeCapacity         edges           list             1
EdgeCost             edges           list             1

EdgeStyle            edges           rules
EdgeShapeFunction    edges           rules
EdgeLabels           edges           rules
EdgeLabelStyle       edges           rules

* VertexCoordinates is special in that it can only be set for an individual vertex if all vertices have already been assigned an explicit coordinate value using SetProperty[graph, VertexCoordinates -> {...}]. It has no default.

A vertex property can be set for individual vertices as SetProperty[{g, vertex}, prop -> value]. Similarly, an edge property can be set for individual edges as SetProperty[{g, edge}, prop -> value]. A graph property can only be set as SetProperty[g, prop -> value] for the complete graph.

List type properties are stored as a list of the same length as the number of elements they refer to (edges or vertices). When setting a list type property for in individual element (vertex or edge), the rest automatically get a default value. When setting a list type property for the whole graph, the length of the list must agree with the number of elements. Example:

SetProperty[g, VertexCapacity -> {1,2,3}] (* list length *must* agree with VertexCount *)

Rule type properties as stored as a list of rules, and may be assigned for a subset of elements (leaving the rest without an explicit value). Example:

g = Graph[{a,b,c}, ...];
SetProperty[g, VertexSize -> {a -> 1, b -> 2}] (* c will not have an assigned VertexSize *)

Rule type properties can also have a default value stored as the first element of the rule list. For certain types of properties (e.g. EdgeStyle), this default will be combined with the individual values. Example:

g = Graph[{1 <-> 2, 2 <-> 3}];    
SetProperty[g, EdgeStyle -> {Thick, 2 \[UndirectedEdge] 3 -> Red}]

Thick will apply to all edges, including 2 <-> 3, while Red will apply only to 2 <-> 3.

$\endgroup$
1
  • $\begingroup$ This may not be complete. Edits are welcome. There is no need to list all global graph properties unless their name is misleading and suggests that they are in fact edge or vertex properties. VertexCoordinates is a graph property not a vertex property. It cannot be set for individual vertices. This is confusing so I listed it. $\endgroup$
    – Szabolcs
    Commented Jun 11, 2016 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.