vertices in a undirected graph will be connected by two edges.
E.g (where "->" and "<-" is representing an edge):
v1 -> v2
v1 <- v1
This fact requires to implement additonal checks in DFS and other graph algorithm.
E.g.:
private static IEnumerable<IEdge> DepthFirstSearch(IVertex current, List<IEdge> edges, IVertex goal)
{
//mark edges
foreach (IEdge e in current.Edges)
{
//check if we found the goal
if (e.V.Equals(goal))
{
//some special behaviour duo circlues which we have to consider resulting of the our model (undirected: 1->3, 3->1)
if (!edges.First().U.Edges.SelectMany(a => a.V.Edges).ToList().Exists(y => y.Equals(e))//schauen ob er zurückgehen will
|| (edges.First().U.Edges.SelectMany(a => a.V.Edges).ToList().Exists(y => y.Equals(e) && //(kreis existiert mit IEdge ausgehend vom start), (schauen ob dazwischen noch andere IEdges sind)
edges.Find(delegate (IEdge ed) { return ed.V == e.U && ed.U != e.V; }) != null)))
{
edges.Add(e);
return edges;
}
[...]
Therefore we should provide a method which considers the opposite edge when checking if the edge was already visitied.
vertices in a undirected graph will be connected by two edges. E.g (where "->" and "<-" is representing an edge): v1 -> v2 v1 <- v1
This fact requires to implement additonal checks in DFS and other graph algorithm. E.g.:
Therefore we should provide a method which considers the opposite edge when checking if the edge was already visitied.