Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
43
Issues
43
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
db7589d6
Commit
db7589d6
authored
Aug 17, 2009
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move graph component code from 'stats' to 'topology' module
parent
6d1a9eff
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
15 additions
and
82 deletions
+15
-82
src/graph/stats/Makefile.am
src/graph/stats/Makefile.am
+0
-2
src/graph/stats/graph_stats_bind.cc
src/graph/stats/graph_stats_bind.cc
+0
-2
src/graph/topology/Makefile.am
src/graph/topology/Makefile.am
+4
-2
src/graph/topology/graph_components.cc
src/graph/topology/graph_components.cc
+0
-0
src/graph/topology/graph_components.hh
src/graph/topology/graph_components.hh
+0
-0
src/graph/topology/graph_topology.cc
src/graph/topology/graph_topology.cc
+3
-0
src/graph_tool/stats/__init__.py
src/graph_tool/stats/__init__.py
+0
-69
src/graph_tool/topology/__init__.py
src/graph_tool/topology/__init__.py
+8
-7
No files found.
src/graph/stats/Makefile.am
View file @
db7589d6
...
...
@@ -11,14 +11,12 @@ libgraph_tool_stats_LTLIBRARIES = libgraph_tool_stats.la
libgraph_tool_stats_la_includedir
=
$(pythondir)
/graph_tool/include
libgraph_tool_stats_la_SOURCES
=
\
graph_components.cc
\
graph_histograms.cc
\
graph_average.cc
\
graph_parallel.cc
\
graph_stats_bind.cc
libgraph_tool_stats_la_include_HEADERS
=
\
graph_components.hh
\
graph_parallel.hh
\
graph_histograms.hh
\
graph_average.hh
...
...
src/graph/stats/graph_stats_bind.cc
View file @
db7589d6
...
...
@@ -17,14 +17,12 @@
using
namespace
boost
;
void
export_components
();
void
export_parallel
();
void
export_histograms
();
void
export_average
();
BOOST_PYTHON_MODULE
(
libgraph_tool_stats
)
{
export_components
();
export_parallel
();
export_histograms
();
export_average
();
...
...
src/graph/topology/Makefile.am
View file @
db7589d6
...
...
@@ -20,6 +20,8 @@ libgraph_tool_topology_la_SOURCES = \
graph_minimum_spanning_tree.cc
\
graph_denominator_tree.cc
\
graph_topological_sort.cc
\
graph_transitive_closure.cc
graph_transitive_closure.cc
\
graph_components.cc
libgraph_tool_topology_la_include_HEADERS
=
libgraph_tool_topology_la_include_HEADERS
=
\
graph_components.hh
src/graph/
stats
/graph_components.cc
→
src/graph/
topology
/graph_components.cc
View file @
db7589d6
File moved
src/graph/
stats
/graph_components.hh
→
src/graph/
topology
/graph_components.hh
View file @
db7589d6
File moved
src/graph/topology/graph_topology.cc
View file @
db7589d6
...
...
@@ -37,6 +37,8 @@ bool denominator_tree(GraphInterface& gi, size_t entry, boost::any pred_map);
void
transitive_closure
(
GraphInterface
&
gi
,
GraphInterface
&
tcgi
);
void
export_components
();
BOOST_PYTHON_MODULE
(
libgraph_tool_topology
)
{
def
(
"check_isomorphism"
,
&
check_isomorphism
);
...
...
@@ -45,4 +47,5 @@ BOOST_PYTHON_MODULE(libgraph_tool_topology)
def
(
"topological_sort"
,
&
topological_sort
);
def
(
"denominator_tree"
,
&
denominator_tree
);
def
(
"transitive_closure"
,
&
transitive_closure
);
export_components
();
}
src/graph_tool/stats/__init__.py
View file @
db7589d6
...
...
@@ -28,7 +28,6 @@ from .. core import _degree, _prop
from
numpy
import
*
__all__
=
[
"vertex_hist"
,
"edge_hist"
,
"vertex_average"
,
"edge_average"
,
"label_components"
,
"label_biconnected_components"
,
"label_parallel_edges"
,
"remove_parallel_edges"
,
"label_self_loops"
,
"remove_self_loops"
,
"remove_labeled_edges"
]
...
...
@@ -243,74 +242,6 @@ def edge_average(g, eprop):
get_edge_average
(
g
.
_Graph__graph
,
_prop
(
"e"
,
g
,
eprop
))
return
ret
def
label_components
(
g
,
vprop
=
None
,
directed
=
None
):
"""
Labels the components to which each vertex in the graph belongs. If the
graph is directed, it finds the strongly connected components.
Parameters
----------
g : Graph
Graph to be used.
vprop : PropertyMap (optional, default: None)
Vertex property to store the component labels. If none is supplied, one
is created.
directed : bool (optional, default:None)
Treat graph as directed or not, independently of its actual
directionality.
Returns
-------
comp : PropertyMap
Vertex property map with component labels.
Notes
-----
The components are arbitrarily labeled from 0 to N-1, where N is the total
number of components.
The algorithm runs in :math:`O(|V| + |E|)` time.
Examples
--------
>>> g = gt.random_graph(100, lambda: (1, 1), seed=42)
>>> comp = gt.label_components(g)
>>> print comp.get_array()
[0 1 2 3 4 0 3 3 4 4 2 3 4 0 3 3 3 3 0 3 2 1 3 0 0 2 2 3 3 3 0 1 2 3 2 3 0
1 0 5 5 1 4 2 2 1 0 3 3 3 3 3 3 0 0 3 4 2 3 2 5 5 0 2 1 0 3 2 0 3 3 0 4 3
2 6 2 2 1 3 1 1 0 3 0 1 3 0 3 0 2 0 2 2 0 6 1 1 0 2]
"""
if
directed
!=
None
:
g
.
stash_filter
(
directed
=
True
)
g
.
set_directed
(
directed
)
if
vprop
==
None
:
vprop
=
g
.
new_vertex_property
(
"int32_t"
)
libgraph_tool_stats
.
\
label_components
(
g
.
_Graph__graph
,
_prop
(
"v"
,
g
,
vprop
))
if
directed
!=
None
:
g
.
pop_filter
(
directed
=
True
)
return
vprop
def
label_biconnected_components
(
g
,
eprop
=
None
,
vprop
=
None
):
if
vprop
==
None
:
vprop
=
g
.
new_vertex_property
(
"bool"
)
if
eprop
==
None
:
eprop
=
g
.
new_edge_property
(
"int32_t"
)
g
.
stash_filter
(
directed
=
True
)
g
.
set_directed
(
False
)
nc
=
libgraph_tool_stats
.
\
label_biconnected_components
(
g
.
_Graph__graph
,
_prop
(
"e"
,
g
,
eprop
),
_prop
(
"v"
,
g
,
vprop
))
g
.
pop_filter
(
directed
=
True
)
return
eprop
,
vprop
,
nc
def
remove_labeled_edges
(
g
,
label
):
g
.
stash_filter
(
all
=
False
,
directed
=
True
,
reversed
=
True
)
libgraph_tool_stats
.
\
...
...
src/graph_tool/topology/__init__.py
View file @
db7589d6
...
...
@@ -31,12 +31,16 @@ __all__ = ["isomorphism", "min_spanning_tree", "denominator_tree",
"topological_sort"
,
"transitive_closure"
,
"label_components"
,
"label_biconnected_components"
]
def
isomorphism
(
g1
,
g2
,
isomap
=
None
):
if
isomap
==
None
:
isomap
=
g1
.
new_vertex_property
(
"int32_t"
)
return
libgraph_tool_topology
.
\
def
isomorphism
(
g1
,
g2
,
isomap
=
False
):
imap
=
g1
.
new_vertex_property
(
"int32_t"
)
iso
=
libgraph_tool_topology
.
\
check_isomorphism
(
g1
.
_Graph__graph
,
g2
.
_Graph__graph
,
_prop
(
"v"
,
g1
,
isomap
))
if
isomap
:
return
iso
,
imap
else
:
return
iso
def
min_spanning_tree
(
g
,
weights
=
None
,
root
=
None
,
tree_map
=
None
):
if
tree_map
==
None
:
...
...
@@ -77,8 +81,6 @@ def topological_sort(g):
libgraph_tool_topology
.
\
topological_sort
(
g
.
_Graph__graph
,
topological_order
)
return
topological_order
<<<<<<<
HEAD
=======
def
transitive_closure
(
g
):
if
not
g
.
is_directed
():
...
...
@@ -164,4 +166,3 @@ def label_biconnected_components(g, eprop=None, vprop=None):
_prop
(
"v"
,
g
,
vprop
))
g
.
pop_filter
(
directed
=
True
)
return
eprop
,
vprop
,
nc
>>>>>>>
3
b8ab1b
...
merge
transitive
closure
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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