Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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], ...}]. –  István Zachar Sep 14 '13 at 7:23
add comment

1 Answer

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}
share|improve this answer
    
Ok, so SetProperty works here. Thanks. –  Ilya Sorokin Sep 14 '13 at 7:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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