質問

I have a simple UNDIRECTED Graph G, and want to reverse an edge if a certain condition is true. The following code gives an error that the EdgeElement constructor is inaccessible:

if(dfsNum[source->index()]>dfsNum[target->index()]){
    EdgeElement ee(target, source, target->firstAdj(), source->firstAdj(), e->index());
    e = ee.theEdge();
}

Is this the correct way of doing what I am doing?

IMPORTANT EDIT: My bad. I do not have to reverse the edge, I have to direct it.

正しい解決策はありません

他のヒント

Based on the documentation, you can delete an edge using delEdge and add a new edge using newEdge. The undirected graph may really be a directional graph with two directed edges for every undirected edge. If that is the case, delete the edge that you do not need anymore. For example, to direct an undirected edge (u, v) from u to v, delete the directed edge (v, u), so the only remaining directed edge is (u, v). You can find an edge to delete using the searchEdge method.

G.reverseEdge(e) reverses edge e in graph G.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top