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
40
Issues
40
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
cc6a4ca2
Commit
cc6a4ca2
authored
Mar 15, 2012
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable generation of self_loops in condensation_graph()
parent
07911562
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
9 deletions
+17
-9
src/graph/community/graph_community.cc
src/graph/community/graph_community.cc
+1
-1
src/graph/community/graph_community_network.cc
src/graph/community/graph_community_network.cc
+7
-4
src/graph/community/graph_community_network.hh
src/graph/community/graph_community_network.hh
+3
-2
src/graph_tool/community/__init__.py
src/graph_tool/community/__init__.py
+6
-2
No files found.
src/graph/community/graph_community.cc
View file @
cc6a4ca2
...
...
@@ -101,7 +101,7 @@ extern void community_network(GraphInterface& gi, GraphInterface& cgi,
boost
::
any
condensed_community_property
,
boost
::
any
vertex_count
,
boost
::
any
edge_count
,
boost
::
any
vweight
,
boost
::
any
eweight
);
boost
::
any
eweight
,
bool
self_loops
);
BOOST_PYTHON_MODULE
(
libgraph_tool_community
)
{
...
...
src/graph/community/graph_community_network.cc
View file @
cc6a4ca2
...
...
@@ -43,6 +43,9 @@ typedef DynamicPropertyMapWrap<python::object,GraphInterface::edge_t> eoweight_m
struct
get_community_network_dispatch
{
get_community_network_dispatch
(
bool
self_loops
)
:
_self_loops
(
self_loops
)
{}
bool
_self_loops
;
template
<
class
Graph
,
class
CommunityGraph
,
class
CommunityMap
,
class
VertexWeightMap
,
class
EdgeWeightMap
,
class
EdgeIndex
,
class
VertexIndex
>
...
...
@@ -66,7 +69,7 @@ struct get_community_network_dispatch
get_community_network
()(
g
,
cg
,
cvertex_index
,
cedge_index
,
s_map
,
cs_map
,
vweight
,
eweight
,
vertex_count
,
edge_count
);
edge_count
,
_self_loops
);
}
struct
get_checked_t
...
...
@@ -104,7 +107,7 @@ void community_network(GraphInterface& gi, GraphInterface& cgi,
boost
::
any
condensed_community_property
,
boost
::
any
vertex_count
,
boost
::
any
edge_count
,
boost
::
any
vweight
,
boost
::
any
eweight
)
boost
::
any
eweight
,
bool
self_loops
)
{
typedef
typename
mpl
::
vector
<
vweight_map_t
,
voweight_map_t
,
no_vweight_map_t
>::
type
vweight_properties
;
...
...
@@ -149,8 +152,8 @@ void community_network(GraphInterface& gi, GraphInterface& cgi,
}
}
run_action
<>
()(
gi
,
bind
<
void
>
(
get_community_network_dispatch
(
),
_1
,
ref
(
cgi
.
GetGraph
()),
cgi
.
GetVertexIndex
(),
run_action
<>
()(
gi
,
bind
<
void
>
(
get_community_network_dispatch
(
self_loops
)
,
_1
,
ref
(
cgi
.
GetGraph
()),
cgi
.
GetVertexIndex
(),
cgi
.
GetEdgeIndex
(),
_2
,
condensed_community_property
,
_3
,
_4
,
make_pair
(
vertex_count
,
edge_count
)),
...
...
src/graph/community/graph_community_network.hh
View file @
cc6a4ca2
...
...
@@ -44,7 +44,8 @@ struct get_community_network
VertexIndex
cvertex_index
,
EdgeIndex
cedge_index
,
CommunityMap
s_map
,
CCommunityMap
cs_map
,
VertexWeightMap
vweight
,
EdgeWeightMap
eweight
,
VertexProperty
vertex_count
,
EdgeProperty
edge_count
)
const
VertexProperty
vertex_count
,
EdgeProperty
edge_count
,
bool
self_loops
)
const
{
typedef
typename
graph_traits
<
Graph
>::
vertex_descriptor
vertex_t
;
typedef
typename
graph_traits
<
Graph
>::
edge_descriptor
edge_t
;
...
...
@@ -98,7 +99,7 @@ struct get_community_network
{
vertex_t
t
=
target
(
*
e
,
g
);
cvertex_t
ct
=
comm_vertices
[
get
(
s_map
,
t
)];
if
(
ct
==
cs
)
// self-loops are pointless
if
(
ct
==
cs
&&
!
self_loops
)
continue
;
cedge_t
ce
;
if
(
comm_edges
.
find
(
make_pair
(
cs
,
ct
))
!=
comm_edges
.
end
())
...
...
src/graph_tool/community/__init__.py
View file @
cc6a4ca2
...
...
@@ -278,7 +278,7 @@ def modularity(g, prop, weight=None):
return
m
def
condensation_graph
(
g
,
prop
,
vweight
=
None
,
eweight
=
None
):
def
condensation_graph
(
g
,
prop
,
vweight
=
None
,
eweight
=
None
,
self_loops
=
False
):
r
"""
Obtain the condensation graph, where each vertex with the same 'prop' value
is condensed in one vertex.
...
...
@@ -293,6 +293,9 @@ def condensation_graph(g, prop, vweight=None, eweight=None):
Vertex property map with the optional vertex weights.
eweight : :class:`~graph_tool.PropertyMap` (optional, default: None)
Edge property map with the optional edge weights.
self_loops : ``bool`` (optional, default: ``False``)
If ``True``, self-loops due to intra-block edges are also included in
the condensation graph.
Returns
-------
...
...
@@ -355,5 +358,6 @@ def condensation_graph(g, prop, vweight=None, eweight=None):
_prop
(
"v"
,
gp
,
vcount
),
_prop
(
"e"
,
gp
,
ecount
),
_prop
(
"v"
,
g
,
vweight
),
_prop
(
"e"
,
g
,
eweight
))
_prop
(
"e"
,
g
,
eweight
),
self_loops
)
return
gp
,
cprop
,
vcount
,
ecount
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