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 asked this question in different form and because I couldn't receive the proper answer so I have to change my question.I know that was my fault sorry.I need to change the Matrix Data of nodes and edges in the graph. How can I do that on the graph itself by clicking on each node?

Graph[{"Uppsala" -> "Marsta", "Marsta" -> "Uppsala", "UpplandsVasby" -> "Sollentuna", "Sollentuna" -> "UpplandsVasby", 
  "UpplandsVasby" -> "Marsta", "Marsta" -> "UpplandsVasby", 
  "Stockholm" -> "Boo", "Boo" -> "Stockholm", 
  "Stockholm" -> "Lidingo", "Lidingo" -> "Stockholm", 
  "Stockholm" -> "Sollentuna", "Sollentuna" -> "Stockholm", 
  "Stockholm" -> "Taby", "Taby" -> "Stockholm"},EdgeWeight -> RandomInteger[{10, 100}, 14] 
 VertexLabels -> "Name"]
share|improve this question
    
What is Matrix Data? –  belisarius May 13 '13 at 14:03
    
You can't do it by clicking on each node. You need to enter commands to set these properties. The command to look up is SetProperty. –  Szabolcs May 13 '13 at 14:04
1  
Can you clarify if your question is about how to set the weights, or about how to set the weights using a graphical point-and-click interface? –  Szabolcs May 13 '13 at 14:09
add comment

1 Answer 1

up vote 2 down vote accepted

The function to use to set properties on graphs is SetProperty. Sometimes this function can be a bit inconsistent and difficult to figure out, but this time the standard syntax works:

SetProperty[{g, "Uppsala" \[DirectedEdge] "Marsta"}, EdgeWeight -> 15]

You could also use

SetProperty[g, EdgeWeight -> {"Uppsala" \[DirectedEdge] "Marsta" -> 20}]

Note the use of \[DirectedEdge] instead of ->. You can enter it using esc de esc. Also note that SetProperty does not change the graph g. It simply return a new graph with the selected property changed. If you need to change the graph, use g = SetProperty[g, ...].

share|improve this answer
    
How can I change on the graph not in the coding?I mean in an interactive just by clicking? –  Alex May 13 '13 at 14:51
1  
@Alex I am not aware of any solution for that in Mathematica. You'd have to write one. You can use some other program (Gephi? Cytoscape? not sure if they can do this), construct the graph, export it to GraphML or a similar format, then import it to Mathematica. –  Szabolcs May 13 '13 at 16:21
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.