Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • graph-tool graph-tool
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 48
    • Issues 48
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Please use the issue tracker only to report bugs (i.e. errors in the library that need to be fixed) or feature requests.

For questions about how to compile, install or use the library, please use instead the web forum at https://forum.skewed.de/c/graph-tool.


(If unsure, use the forum first.)


IMPORTANT: When opening new issues, please choose the BUG template from the drop-down menu, and fill out the required information.

  • Tiago Peixoto
  • graph-toolgraph-tool
  • Issues
  • #728
Closed
Open
Issue created Jan 19, 2022 by Sergey M@SergeyMironov

`iter_all_edges` doesn't honor `set_reversed` status

I'm using graph_tool-2.43. Consider the following code. The giter_all_edges is a wrapper that needs to manually check the reversed status and adjust the order of edges. I assume that this is a bug, since giter_edges doesn't have to do this.

from graph_tool import (Graph, Vertex, Edge, GraphView)

def giter_all_edges(g:Graph,v,eprops=[]):                                        
  for xs in g.iter_all_edges(v,eprops):                                          
    yield tuple([xs[1],xs[0]]+xs[2:]) if g.is_reversed() else xs # <-- Need to manually reverse nodes (!!!)

def giter_edges(g:Graph,eprops=[]):                                              
  for xs in g.iter_edges(eprops):                                                
    yield xs                                                                     
             
# Create a 2-node graph with an edge
g=Graph(directed=True)                                                         
v1=g.add_vertex()                                                              
v2=g.add_vertex()                                                              
e1=g.edge(v1,v2,add_missing=True)                                              
eprop=g.new_ep('int64_t')                                                      
edges={}                                                                       
for s,t in g.iter_edges([]):                                                   
  eprop[g.edge(s,t)]=111                                                       
  edges[s]=t                                                                   
assert len(edges)==1              

# Make sure that iterators work correctly                                             
for s,t,e in giter_all_edges(g,v1,[eprop]):                                    
  assert eprop[g.edge(s,t)]==111                                               
  assert edges[s]==t                                                           
for s,t,e in giter_edges(g,[eprop]):                                           
  assert eprop[g.edge(s,t)]==111                                               
  assert edges[s]==t                     

# Reverse the graph                                      
g.set_reversed(True) 

# Oh no, without the wrapper this would fail                                                          
for s,t,e in giter_all_edges(g,v1,[eprop]):                                    
  assert eprop[g.edge(s,t)]==111                                               
  assert edges[t]==s                    
# .. and this would not                                       
for s,t,e in giter_edges(g,[eprop]):                                           
  assert eprop[g.edge(s,t)]==111                                               
  assert edges[t]==s                                                            
Edited Jan 19, 2022 by Sergey M
Assignee
Assign to
Time tracking