-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hydrofabric network cycle detection #718
base: master
Are you sure you want to change the base?
Conversation
std::string msg = "The following features form a cycle:\n"; | ||
for(auto p : cycles){ | ||
msg += "\t"+get_id(p.first)+" --> "+get_id(p.second)+"\n"; | ||
} | ||
throw std::domain_error("Cycle(s) detected in hydrofabric\n"+msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As phrased, this message might confusingly suggest that the identifying elements of distinct cycles are actually the set of elements in a single cycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would something like
Cycle(s) detected in hydrofabric
The following features form the connecting edge of a cycle:
nex-1 --> cat-0
be more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's an improvement. Maybe "The following features each form the connecting edge of a cycle" (added 'each')?
I realize we probably don't need to word-smith this much more, since anyone encountering this is pretty likely to make their way back to us to help with getting it resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like added "each" to be clear when multiple cycles are found. I'll touch it up and rebase.
detect_cycles vis(&cycles); | ||
//Run an undirected, depth first search applying the loop detector visitor | ||
//cycles added as vertex pairs for the closing edge of the cycle | ||
boost::undirected_dfs(this->graph, vis, make_assoc_property_map(vis.vertex_coloring), make_assoc_property_map(vis.edge_coloring)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detect_cycles vis(&cycles); | |
//Run an undirected, depth first search applying the loop detector visitor | |
//cycles added as vertex pairs for the closing edge of the cycle | |
boost::undirected_dfs(this->graph, vis, make_assoc_property_map(vis.vertex_coloring), make_assoc_property_map(vis.edge_coloring)); | |
detect_cycles cycles_visitor(&cycles); | |
//Run an undirected, depth first search applying the loop detector visitor | |
//cycles added as vertex pairs for the closing edge of the cycle | |
boost::undirected_dfs(this->graph, cycles_visitor, make_assoc_property_map(vis.vertex_coloring), make_assoc_property_map(vis.edge_coloring)); |
Just making the name a bit more verbose for clarity. Alternately,
detect_cycles vis(&cycles); | |
//Run an undirected, depth first search applying the loop detector visitor | |
//cycles added as vertex pairs for the closing edge of the cycle | |
boost::undirected_dfs(this->graph, vis, make_assoc_property_map(vis.vertex_coloring), make_assoc_property_map(vis.edge_coloring)); | |
//Run an undirected, depth first search applying the loop detector visitor | |
//cycles added as vertex pairs for the closing edge of the cycle | |
boost::undirected_dfs(this->graph, detect_cycles(&cycles), make_assoc_property_map(vis.vertex_coloring), make_assoc_property_map(vis.edge_coloring)); |
Just don't name the temporary visitor object at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I like the latter a bit better
Cycles in the hydrofabric topology can cause a
boost::not_a_dag
exception to occur (when performing topological sort of the graph, for example.)This exception, however, doesn't provide any useful context to determine what part of the hydrofabric creates/contributes to the cycle to be investigated.
This PR provides a custom cycle detection visitor which records the vertices of all back edges in the graph. This visitor is then used in the
init_indicies
function of all network creation to run an undirected depth first search and record the cycles. All cycles are identified and the vertices are mapped back to the hydrofabric ID and reported in astd::domain_error
exception message that looks likeAdditions
detect_cycles
visitorRemovals
Changes
std::domain_error
thrown in network creation when cycles are detectedTesting
Network
using a topology which has a cycleNotes
Some additional code is left in the visitor implementation commented out. If additional information about hydrofabric features involved in the cycle are needed, it can be used to provide all vertices related to a reported cycle.
Checklist
Target Environment support