GraphTea icon indicating copy to clipboard operation
GraphTea copied to clipboard

dfs function on AlgorithmUtils.java doesn't work properly

Open Welcius opened this issue 11 years ago • 0 comments

IsEulerian still doesn't work because isConnected fails due an error on the dfs function on AlgorithmUtils.java, seems that it only gets executed once. (tried debugging it by myself but I am not familiar with java and the project itself yet).

The code of the faulty dfs function it's this one:

public static <VertexType extends BaseVertex, EdgeType extends BaseEdge<VertexType>>
void dfs(BaseGraph<VertexType, EdgeType> g,
         int node, ArrayList visit, int parent[]) {
    visit.add(node);
    ArrayList e = getAdjList(g);
    ArrayList neighbors = (ArrayList) e.get(node);
    for (Object neighbor1 : neighbors) {
        int neighbor = (Integer) neighbor1;
        if (parent[neighbor] == -1) {
            parent[neighbor] = node;
            dfs(g, neighbor, visit, parent);
        }
    }
}

Welcius avatar Oct 26 '15 22:10 Welcius