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
  • #170
Closed
Open
Issue created Aug 08, 2014 by Dominik@Dominik

GraphView without efilt

I am not sure if this is a bug or a feature.

Code:

import graph_tool.all as gt

def implicit_efilt(vfilt):
  G = vfilt.get_graph()
  efilt = G.new_edge_property("bool")
  efilt.a = False
  Gv = gt.GraphView(G,vfilt=vfilt)
  for e in Gv.edges(): efilt[e] = True
  return efilt

def format_vlist(G):
  return ",".join(map(str,G.vertices()))
  
def format_elist(G):
  return ",".join(["({}->{})".format(e.source(),e.target()) for e in G.edges()])


  
G = gt.complete_graph(4)

print("G " + format_vlist(G) + " - " + format_elist(G))


vfilt = G.new_vertex_property("bool")
vfilt.a = True
vfilt[G.vertex(0)] = False


Gv = gt.GraphView(G,vfilt=vfilt)

print("Gv " + format_vlist(Gv) + " - " + format_elist(Gv))

for e in G.edges():  
  if Gv.edge(e.source(),e.target()) is not None: 
    print("Edge ({}->{}) is in Gv".format(e.source(),e.target()))
  else:
    print("Edge ({}->{}) is NOT in Gv".format(e.source(),e.target()))
 

Gv = gt.GraphView(G,vfilt=vfilt, efilt=implicit_efilt(vfilt))

print("Gv " + format_vlist(Gv) + " - " + format_elist(Gv))

for e in G.edges():  
  if Gv.edge(e.source(),e.target()) is not None: 
    print("Edge ({}->{}) is in Gv".format(e.source(),e.target()))
  else:
    print("Edge ({}->{}) is NOT in Gv".format(e.source(),e.target()))

Output

G 0,1,2,3 - (0->1),(0->2),(0->3),(1->2),(1->3),(2->3)
Gv 1,2,3 - (1->2),(1->3),(2->3)
Edge (0->1) is in Gv
Edge (0->2) is in Gv
Edge (0->3) is in Gv
Edge (1->2) is in Gv
Edge (1->3) is in Gv
Edge (2->3) is in Gv
Gv 1,2,3 - (1->2),(1->3),(2->3)
Edge (0->1) is NOT in Gv
Edge (0->2) is NOT in Gv
Edge (0->3) is NOT in Gv
Edge (1->2) is in Gv
Edge (1->3) is in Gv
Edge (2->3) is in Gv

The edge iterator of the filtered graph returns only edges between visible vertices. But the g.edge(s,t) method allows to retrieve edges between filtered vertices. Clearly, the edge filter is needed. Maybe it can be computed if only the vertex filter is given, or we simply update the documentation to explicitly describe the current behavior when an edge filter is not set?

Assignee
Assign to
Time tracking