3
$\begingroup$

I create a Graph which vertices are lists (points in n-dimensional space)

v1 = {{1, 2} -> {3, 4}, {5, 6} -> {7, 8}};
g1 = Graph[v1];
PropertyValue[{g1, VertexList[g1][[1]]}, VertexWeight] = 10

and I get a message error:

Set::write: Tag PropertyValue in PropertyValue[...] is protected

Now, if I do

v2 = {1 -> 2, 3 -> 4};
g2 = Graph[v2];
PropertyValue[{g2, VertexList[g2][[1]]}, VertexWeight] = 10

everything is fine.

g1 and g2 are structurally indentical, the difference is only in vertices type: list(g1) and scalar(g2).

What's the problem here?

$\endgroup$
1
  • $\begingroup$ I think it is better not to use lists as vertices as it can introduce all sorts of similar interferences. I would advice you to use another wrapper instead of List, e.g. Graph[{f[1,2]->f[3,4], ...}]. $\endgroup$ Commented Sep 14, 2013 at 7:23

1 Answer 1

2
$\begingroup$

It works if you specify weights in the following way:

g = Graph[{{1, 2} -> {3, 4}, {5, 6} -> {7, 8}}];
g = SetProperty[g, VertexWeight -> {{1, 2} -> 10}];
PropertyValue[g, VertexWeight]
{10, 1, 1, 1}
$\endgroup$
1
  • $\begingroup$ Ok, so SetProperty works here. Thanks. $\endgroup$ Commented Sep 14, 2013 at 7: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.