File: kcore.py

package info (click to toggle)
graph-tool 2.98%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,324 kB
  • sloc: cpp: 87,937; python: 31,476; makefile: 952; xml: 101; sh: 42
file content (20 lines) | stat: -rw-r--r-- 575 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import graph_tool

# We import the C++ module (called libkcore.so)
import libkcore

# The function below is what will be used from Python, and dispatch to the the
# C++ module.

def kcore_decomposition(g, core=None):
    if core is None:
        core = g.new_vertex_property("int")

    # For graph objects wee need to pass the internal GraphInterface which is
    # assessed via g._Graph__graph.

    # Property maps need to be passed as boost::any objects, which is done via
    # the _get_any() method.

    libkcore.kcore(g._Graph__graph, core._get_any())
    return core