I have a simple functional programming question: I have a simple EdgeList defined in Mathematica, I would like to modify the value of certain element of the list based on a condition.
I see how to define the conditional If, but I don't know how to "scan" my EdgeList and modify the elements so that it returns another EdgeList.
Could someone show me a simple example on how to accomplish this in Mathematica?
|
|
||||
|
First a list of
Let's say you want to change all edges where the head is
The trick is to apply the rule to all edges but only change those which match your
There are many more ways and the more experienced users will probably use such a map with a pure Update for increasing numbersTo
|
||||
|
{a \[UndirectedEdge] b, b \[UndirectedEdge] c, c \[UndirectedEdge] a} /. a \[UndirectedEdge] x_ :> a \[UndirectedEdge] y– ssch Dec 30 '12 at 12:43