Commit b0c2a3c3 authored by Tiago Peixoto's avatar Tiago Peixoto

Move random_rewire() to 'generation' module

parent 400a8d1e
......@@ -15,7 +15,9 @@ libgraph_tool_generation_la_LIBADD = $(MOD_LIBADD)
libgraph_tool_generation_la_LDFLAGS = $(MOD_LDFLAGS)
libgraph_tool_generation_la_SOURCES = \
graph_generation.cc
graph_generation.cc \
graph_rewiring.cc
libgraph_tool_generation_la_include_HEADERS = \
graph_generation.hh
graph_generation.hh \
graph_rewiring.hh
......@@ -94,7 +94,13 @@ void generate_random_graph(GraphInterface& gi, size_t N,
gi.ReIndexEdges();
}
void random_rewire(GraphInterface& gi, string strat, bool self_loops,
bool parallel_edges, size_t seed);
using namespace boost::python;
BOOST_PYTHON_MODULE(libgraph_tool_generation)
{
def("gen_random_graph", &generate_random_graph);
def("random_rewire", &random_rewire);
}
......@@ -15,9 +15,7 @@ libgraph_tool_misc_la_LIBADD = $(MOD_LIBADD)
libgraph_tool_misc_la_LDFLAGS = $(MOD_LDFLAGS)
libgraph_tool_misc_la_SOURCES = \
graph_rewiring.cc \
graph_misc.cc \
graph_isomorphism.cc
libgraph_tool_misc_la_include_HEADERS = \
graph_rewiring.hh
libgraph_tool_misc_la_include_HEADERS =
......@@ -22,13 +22,10 @@ using namespace boost;
using namespace boost::python;
using namespace graph_tool;
void random_rewire(GraphInterface& gi, string strat, bool self_loops,
bool parallel_edges, size_t seed);
bool check_isomorphism(GraphInterface& gi1, GraphInterface& gi2,
boost::any iso_map);
BOOST_PYTHON_MODULE(libgraph_tool_misc)
{
def("random_rewire", &random_rewire);
def("check_isomorphism", &check_isomorphism);
}
......@@ -27,7 +27,7 @@ dl_import("import libgraph_tool_generation")
from .. core import Graph
import sys, numpy
__all__ = ["random_graph"]
__all__ = ["random_graph", "random_rewire"]
def _corr_wrap(i, j, corr):
return corr(i[1], j[1])
......@@ -217,3 +217,18 @@ def random_graph(N, deg_sampler, deg_corr=None, directed=True,
seed, verbose)
g.set_directed(directed)
return g
def random_rewire(g, strat="uncorrelated", self_loops = False,
parallel_edges = False, seed = 0):
if seed != 0:
seed = random.randint(0, sys.maxint)
if g.is_reversed():
was_reversed = True
else:
was_reversed = False
g.set_reversed(False)
libgraph_tool_generation.random_rewire(g._Graph__graph, strat, self_loops,
parallel_edges, seed)
if was_reversed:
g.set_reversed(True)
......@@ -26,21 +26,7 @@ dl_import("import libgraph_tool_misc")
from .. core import _prop
import random, sys
__all__ = ["random_rewire", "isomorphism"]
def random_rewire(g, strat="uncorrelated", self_loops = False,
parallel_edges = False, seed = 0):
if seed != 0:
seed = random.randint(0, sys.maxint)
if g.is_reversed():
was_reversed = True
else:
was_reversed = False
g.set_reversed(False)
libgraph_tool_misc.random_rewire(g._Graph__graph, strat, self_loops,
parallel_edges, seed)
if was_reversed:
g.set_reversed(True)
__all__ = ["isomorphism"]
def isomorphism(g1, g2, isomap=None):
if isomap == None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment