Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
b0c2a3c3
Commit
b0c2a3c3
authored
Aug 04, 2009
by
Tiago Peixoto
Browse files
Move random_rewire() to 'generation' module
parent
400a8d1e
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/graph/generation/Makefile.am
View file @
b0c2a3c3
...
...
@@ -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
src/graph/generation/graph_generation.cc
View file @
b0c2a3c3
...
...
@@ -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
);
}
src/graph/
misc
/graph_rewiring.cc
→
src/graph/
generation
/graph_rewiring.cc
View file @
b0c2a3c3
File moved
src/graph/
misc
/graph_rewiring.hh
→
src/graph/
generation
/graph_rewiring.hh
View file @
b0c2a3c3
File moved
src/graph/misc/Makefile.am
View file @
b0c2a3c3
...
...
@@ -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
=
src/graph/misc/graph_misc.cc
View file @
b0c2a3c3
...
...
@@ -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
);
}
src/graph_tool/generation/__init__.py
View file @
b0c2a3c3
...
...
@@ -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
)
src/graph_tool/misc/__init__.py
View file @
b0c2a3c3
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment