graph.reachable_paths: branching does not work in subpaths
While playing around with graph.reachable_paths, I noticed that traversing into "neighbors" only seems to work for the root node, not neighboring nodes encountered along the way. The below example correctly branches off att the ceo node (which is where we begin the search for paths), creating one subpath for human_resources and secret_services. The secret_services node however contains two neighbors, and I would expect both of them to create new paths. Instead, some odd behavior is triggered, where the ceo and secret_services nodes are appended twice to the second path array.
package graph_reachable_paths
ceo_paths := p {
shady_org_graph := {
"ceo": ["human_resources", "secret_services"],
"human_resources": ["staffing"],
"internships": [],
"staffing": ["internships"],
"secret_services": ["spies", "specialt_unit"],
"special_unit": ["assassins"],
"spies": ["agents"],
"agents": [],
"assassins": []
}
p := graph.reachable_paths(shady_org_graph, {"ceo"})
}
Expected result
{
"ceo_paths": [
[
"ceo",
"human_resources",
"staffing",
"internships"
],
[
"ceo",
"secret_services",
"spies",
"agents"
],
[
"ceo",
"secret_services",
"special_unit",
"assassins"
]
]
}
Actual result
{
"ceo_paths": [
[
"ceo",
"human_resources",
"staffing",
"internships"
],
[
"ceo",
"secret_services",
"spies",
"agents",
"ceo",
"secret_services"
]
]
}
Rego Playground: https://play.openpolicyagent.org/p/uOtBvcxUs3
Finally, if anyone knows any skilled assassins, I heard shady org is hiring!
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days.