ITensor / ITensor/NamedGraphs.jl
[BUG] Edge_subgraph fails due to implicitly caring about edge directionality on undirected graphs
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 10
- Forks
- 5
- Avg merge
- 6h 43m
- Merged PRs (30d)
- 17
Description
In the current version of the library (0.12), edge_subgraph(g::NamedGraph, es::AbstractVector) is returning incorrect results.
For instance the last assertion here fails.
using NamedGraphs
using NamedGraphs.NamedGraphGenerators: named_hexagonal_lattice_graph
using NamedGraphs: NamedEdge, edges
using NamedGraphs.GraphsExtensions: edge_subgraph
g = named_hexagonal_lattice_graph(3, 3)
#Ring of six edges in the graph
es = NamedEdge.([(1, 1) => (2, 1), (2, 1) => (3, 1), (3, 1) => (3, 2), (2, 2) => (3, 2), (1, 2) => (2, 2), (1, 1) => (1, 2)])
#They are all in `g` (and specified in the correct direction)
@assert all([e ∈ edges(g) for e in es])
#Build the subgraph from these edges
eg = edge_subgraph(g,es)
#But now one of them is missing from the subgraph they induce...
@assert length(edges(eg)) == length(es)
but passes on older versions of the library (0.7 for instance).
This appears to be due to the fact that internally in edge_subgraph the call to _g = subgraph(g, vs) builds a subgraph with edges that may be defined in reverse compared to the original graph g and then the edge subgraph is built by removing a setdiff(edges(g), es) from _g which cares about edge directionality.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at GraphsExtensions.edge_subgraph and reproduce the provided named_hexagonal_lattice_graph example, then inspect its subgraph and setdiff handling for undirected edges. Done means the resulting subgraph retains all six edges in es, including edges whose stored direction is reversed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100