0
$\begingroup$

I want to find all possible path in the graph, except (<-) direction. it's my code.

eg611 = GridGraph[{7, 4}, DirectedEdges -> False, VertexLabels -> "Name"]
eg6111 = SetProperty[eg611, VertexCoordinates -> GraphEmbedding[eg611]];
eg6112 = EdgeDelete[eg6111, {18 -> 25, 17 -> 24, 16 -> 23, 13 -> 20, 12 -> 19,10 -> 17,9 -> 16, 2 -> 9, 6 -> 13, 4 -> 11}]
FindPath[eg6112, 1, 28, Infinity, All]

and i don't know why output include:

{1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 21,....

i already deleted the edge between 2 and 9 vertex, why it still find the path include 9 to 2

$\endgroup$
4
$\begingroup$

You did EdgeDelete[eg6111, {..., 2 -> 9, ...}] and the documentation for EdgeDelete, hidden behind Details, says

An undirected edge can be specified using v<->w or UndirectedEdge[v,w].

A directed edge can be specified using v->w or DirectedEdge[v,w].

So you deleted a directed edge from from 2 to 9 from your graph but you didn't delete the edge from 9 to 2 from your graph.

If you change that to EdgeDelete[eg6111, {..., 2 <-> 9, ...}] then it appears that your problem with the ...,9,2,... disappears from your output. But it isn't clear from your description exactly what you really wanted to delete.

Always, well almost always, click on Details and read the hidden surprises there when using any function in Mathematica.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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