Filter graph seems to count degree twice for undirected graphs
The code for the filtered graph seems to lack the notions necessary for undirected graphs when it comes to the counting of degrees. This is reflected on the kcore_decomposition that I am using and I have tried to fix this issue.
I have forked your repository for my own use (Long live GPL!) and I have committed the fix on my repository at GitHub on top of your commit: 635b9675 . I think my edit fixes the issue (and brings the output to the expected one, see below), but I am not sure if it breaks something else, so it definitely needs some further insight with someone with more experience in the code.
Testcase in python:
from graph_tool import topology, Vertex, Graph, GraphView
def show_info(tag, g):
for deg in ('in','out','total'):
print("{0!s:15}: degrees {1!s:5}:".format(tag, deg), tuple(g.degree_property_map(deg)))
print("{0!s:15}: kcore-decomp.:".format(tag), tuple(topology.kcore_decomposition(g)))
g = Graph(directed=False)
edges = ((0, 3),(0, 4),(1, 3),(1, 0),(2, 1),(2, 3),(4, 2),(4, 3),(5, 8),(5, 6),(6, 8),(7, 8),(7, 5),(9, 0),(10, 2),(11, 7),(12, 4))
g.add_edge_list(edges)
vfilt = g.new_vertex_property('bool',True)
show_info("Original graph", g)
gv = GraphView(g,vfilt)
show_info("Graph View", g)
g.set_vertex_filter(vfilt)
show_info("Filtered graph", g)
Actual Output: (notice the last line)
Original graph : degrees in : (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Original graph : degrees out : (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Original graph : degrees total: (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Original graph : kcore-decomp.: (3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1)
Graph View : degrees in : (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Graph View : degrees out : (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Graph View : degrees total: (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Graph View : kcore-decomp.: (3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1)
Filtered graph : degrees in : (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Filtered graph : degrees out : (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Filtered graph : degrees total: (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Filtered graph : kcore-decomp.: (6, 6, 6, 6, 6, 5, 4, 5, 5, 2, 2, 2, 2)
Expected output:
Original graph : degrees in : (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Original graph : degrees out : (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Original graph : degrees total: (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Original graph : kcore-decomp.: (3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1)
Graph View : degrees in : (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Graph View : degrees out : (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Graph View : degrees total: (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Graph View : kcore-decomp.: (3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1)
Filtered graph : degrees in : (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
Filtered graph : degrees out : (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Filtered graph : degrees total: (4, 3, 4, 4, 4, 3, 2, 3, 3, 1, 1, 1, 1)
Filtered graph : kcore-decomp.: (3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1)
Regards,
Janis