Skip to main content
deleted 142 characters in body
Source Link

There is a list of UndirectedEdge:

list=list = {1 \[UndirectedEdge]<-> 2, 2 \[UndirectedEdge]<-> 3, 4 \[UndirectedEdge]<-> 5}

How to change it to:

{101 \[UndirectedEdge]<-> 102, 102 \[UndirectedEdge]<-> 103,  104 \[UndirectedEdge]<-> 105}

?


I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ \[UndirectedEdge]<-> y_ /; x + 100 \[UndirectedEdge]<-> y + 100;
list /. x_UndirectedEdge /; First[x] \[UndirectedEdge]<-> Last[x]
list /. x_UndirectedEdge /; x :> First[x] \[UndirectedEdge]<-> Last[x];

but they are not working correctly.

There is a list of UndirectedEdge:

list={1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 4 \[UndirectedEdge] 5}

How to change it to:

{101 \[UndirectedEdge] 102, 102 \[UndirectedEdge] 103,  104 \[UndirectedEdge] 105}

I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ \[UndirectedEdge] y_ /; x + 100 \[UndirectedEdge] y + 100;
list /. x_UndirectedEdge /; First[x] \[UndirectedEdge] Last[x]
list /. x_UndirectedEdge /; x :> First[x] \[UndirectedEdge] Last[x];

but they are not working correctly.

There is a list of UndirectedEdge:

list = {1 <-> 2, 2 <-> 3, 4 <-> 5}

How to change it to:

{101 <-> 102, 102 <-> 103,  104 <-> 105}

?


I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ <-> y_ /; x + 100 <-> y + 100;
list /. x_UndirectedEdge /; First[x] <-> Last[x]
list /. x_UndirectedEdge /; x :> First[x] <-> Last[x];

but they are not working correctly.

added 1 character in body; edited title
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

How to change argumanarguments of UndirectedEdge

There is a list of UndirectedEdge UndirectedEdge:

list={1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 4 \[UndirectedEdge] 5}

How to change it to:

{101 \[UndirectedEdge] 102, 102 \[UndirectedEdge] 103,  104 \[UndirectedEdge] 105}

I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ \[UndirectedEdge] y_ /; x + 100 \[UndirectedEdge] y + 100;
list /. x_UndirectedEdge /; First[x] \[UndirectedEdge] Last[x]
list /. x_UndirectedEdge /; x :> First[x] \[UndirectedEdge] Last[x];

but they are not working correctly.

How to change arguman of UndirectedEdge

There is a list of UndirectedEdge :

list={1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 4 \[UndirectedEdge] 5}

How to change it to:

{101 \[UndirectedEdge] 102, 102 \[UndirectedEdge] 103,  104 \[UndirectedEdge] 105}

I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ \[UndirectedEdge] y_ /; x + 100 \[UndirectedEdge] y + 100;
list /. x_UndirectedEdge /; First[x] \[UndirectedEdge] Last[x]
list /. x_UndirectedEdge /; x :> First[x] \[UndirectedEdge] Last[x];

but they are not working correctly.

How to change arguments of UndirectedEdge

There is a list of UndirectedEdge:

list={1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 4 \[UndirectedEdge] 5}

How to change it to:

{101 \[UndirectedEdge] 102, 102 \[UndirectedEdge] 103,  104 \[UndirectedEdge] 105}

I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ \[UndirectedEdge] y_ /; x + 100 \[UndirectedEdge] y + 100;
list /. x_UndirectedEdge /; First[x] \[UndirectedEdge] Last[x]
list /. x_UndirectedEdge /; x :> First[x] \[UndirectedEdge] Last[x];

but they are not working correctly.

Source Link
jack cilba
  • 367
  • 1
  • 9

How to change arguman of UndirectedEdge

There is a list of UndirectedEdge :

list={1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 4 \[UndirectedEdge] 5}

How to change it to:

{101 \[UndirectedEdge] 102, 102 \[UndirectedEdge] 103,  104 \[UndirectedEdge] 105}

I tried :

list /. UndirectedEdge[x_, y_] /; x :> x + 100;
list /. x_ \[UndirectedEdge] y_ /; x + 100 \[UndirectedEdge] y + 100;
list /. x_UndirectedEdge /; First[x] \[UndirectedEdge] Last[x]
list /. x_UndirectedEdge /; x :> First[x] \[UndirectedEdge] Last[x];

but they are not working correctly.