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
1845dd07
Commit
1845dd07
authored
Mar 11, 2012
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve label_self_loops()
parent
f2bdc674
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
11 deletions
+17
-11
src/graph/stats/graph_parallel.cc
src/graph/stats/graph_parallel.cc
+3
-2
src/graph/stats/graph_parallel.hh
src/graph/stats/graph_parallel.hh
+2
-2
src/graph_tool/stats/__init__.py
src/graph_tool/stats/__init__.py
+12
-7
No files found.
src/graph/stats/graph_parallel.cc
View file @
1845dd07
...
...
@@ -37,12 +37,13 @@ void do_label_parallel_edges(GraphInterface& gi, boost::any property,
edge_scalar_properties
())(
property
);
}
void
do_label_self_loops
(
GraphInterface
&
gi
,
boost
::
any
property
)
void
do_label_self_loops
(
GraphInterface
&
gi
,
boost
::
any
property
,
bool
mark_only
)
{
GraphInterface
::
edge_index_map_t
edge_index
=
any_cast
<
GraphInterface
::
edge_index_map_t
>
(
gi
.
GetEdgeIndex
());
run_action
<>
()(
gi
,
bind
<
void
>
(
label_self_loops
(),
_1
,
edge_index
,
_2
),
edge_index
,
_2
,
mark_only
),
edge_scalar_properties
())(
property
);
}
...
...
src/graph/stats/graph_parallel.hh
View file @
1845dd07
...
...
@@ -72,7 +72,7 @@ struct label_self_loops
{
template
<
class
Graph
,
class
EdgeIndexMap
,
class
SelfMap
>
void
operator
()(
const
Graph
&
g
,
EdgeIndexMap
edge_index
,
SelfMap
self
)
const
SelfMap
self
,
bool
mark_only
)
const
{
typedef
typename
graph_traits
<
Graph
>::
edge_descriptor
edge_t
;
...
...
@@ -89,7 +89,7 @@ struct label_self_loops
for
(
tie
(
e
,
e_end
)
=
out_edges
(
v
,
g
);
e
!=
e_end
;
++
e
)
{
if
(
target
(
*
e
,
g
)
==
v
)
put
(
self
,
*
e
,
n
++
);
put
(
self
,
*
e
,
mark_only
?
1
:
n
++
);
else
put
(
self
,
*
e
,
0
);
}
...
...
src/graph_tool/stats/__init__.py
View file @
1845dd07
...
...
@@ -303,16 +303,21 @@ def remove_parallel_edges(g):
remove_labeled_edges
(
g
,
eprop
)
def
label_self_loops
(
g
,
eprop
=
None
):
def
label_self_loops
(
g
,
mark_only
=
False
,
eprop
=
None
):
"""Label edges which are self-loops, i.e, the source and target vertices are
the same. Self-loops are labeled with 1 and others with 0. If the `eprop`
parameter is given (a :class:`~graph_tool.PropertyMap`), the labelling is
stored there."""
the same. For each self-loop edge set :math:`SL`, the labelling starts from 0
to :math:`|SL|-1`. If `mark_only == True`, self-loops are labeled with 1
and others with 0. If the `eprop` parameter is given
(a :class:`~graph_tool.PropertyMap`), the labelling is stored there."""
if
eprop
==
None
:
eprop
=
g
.
new_edge_property
(
"int32_t"
)
if
eprop
is
None
:
if
mark_only
:
eprop
=
g
.
new_edge_property
(
"bool"
)
else
:
eprop
=
g
.
new_edge_property
(
"int32_t"
)
libgraph_tool_stats
.
\
label_self_loops
(
g
.
_Graph__graph
,
_prop
(
"e"
,
g
,
eprop
))
label_self_loops
(
g
.
_Graph__graph
,
_prop
(
"e"
,
g
,
eprop
),
mark_only
)
return
eprop
...
...
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