Skip to content
GitLab
Menu
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
6b764b67
Commit
6b764b67
authored
Nov 14, 2006
by
Tiago Peixoto
Browse files
converted tabs to spaces (emacs, why have you forsaken me?)
git-svn-id:
https://svn.forked.de/graph-tool/trunk@58
d4600afd-f417-0410-95de-beed9576f240
parent
dbb7bb2c
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
src/graph-tool
View file @
6b764b67
...
...
@@ -311,23 +311,23 @@ def generate_graph(parameters):
def
parse_option
(
opt
,
just_file
=
False
):
"this will execute an option, and return either None, or a tuple with the result and the respective file name, if it exists"
if
opt
.
name
==
"load"
:
values
=
parse_values
(
opt
.
value
)
if
len
(
values
)
>
2
or
len
(
values
)
<
1
:
raise
OptionError
(
opt
.
name
,
"invalid value '$s'"
%
opt
.
value
)
values
=
parse_values
(
opt
.
value
)
if
len
(
values
)
>
2
or
len
(
values
)
<
1
:
raise
OptionError
(
opt
.
name
,
"invalid value '$s'"
%
opt
.
value
)
if
just_file
:
return
None
if
len
(
values
)
==
1
:
graph
.
ReadFromFile
(
values
[
0
])
if
len
(
values
)
==
1
:
graph
.
ReadFromFile
(
values
[
0
])
else
:
graph
.
ReadFromFile
(
values
[
0
],
values
[
1
])
elif
opt
.
name
==
"save"
:
values
=
parse_values
(
opt
.
value
)
values
=
parse_values
(
opt
.
value
)
if
len
(
values
)
>
2
or
len
(
values
)
<
1
:
raise
OptionError
(
opt
.
name
,
"invalid value '$s'"
%
opt
.
value
)
raise
OptionError
(
opt
.
name
,
"invalid value '$s'"
%
opt
.
value
)
if
just_file
:
return
None
if
len
(
values
)
==
1
:
graph
.
WriteToFile
(
values
[
0
])
if
len
(
values
)
==
1
:
graph
.
WriteToFile
(
values
[
0
])
else
:
graph
.
WriteToFile
(
values
[
0
],
values
[
1
])
elif
opt
.
name
==
"correlated-configurational-model"
:
...
...
src/graph/graph.cc
View file @
6b764b67
...
...
@@ -52,12 +52,12 @@ pair<GraphInterface::degree_t,string> graph_tool::get_degree_type(GraphInterface
string
name
;
try
{
deg
=
boost
::
get
<
GraphInterface
::
degree_t
>
(
degree
);
deg
=
boost
::
get
<
GraphInterface
::
degree_t
>
(
degree
);
}
catch
(
bad_get
)
{
name
=
boost
::
get
<
std
::
string
>
(
degree
);
deg
=
GraphInterface
::
SCALAR
;
name
=
boost
::
get
<
std
::
string
>
(
degree
);
deg
=
GraphInterface
::
SCALAR
;
}
return
make_pair
(
deg
,
name
);
}
...
...
@@ -95,27 +95,27 @@ void GraphInterface::SetVertexFilterProperty(string property)
if
(
property
!=
""
)
{
try
{
dynamic_property_map
&
pmap
=
find_property_map
(
_properties
,
property
,
typeid
(
graph_traits
<
multigraph_t
>::
vertex_descriptor
));
if
(
get_static_property_map
<
vector_property_map
<
double
,
vertex_index_map_t
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
vector_property_map
<
double
,
vertex_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
double
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
double
>
>
(
pmap
);
else
if
(
get_static_property_map
<
vector_property_map
<
size_t
,
vertex_index_map_t
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
vector_property_map
<
size_t
,
vertex_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
size_t
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
size_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
vertex_index_map_t
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
vertex_index_map_t
>
(
pmap
);
else
_vertex_filter_map
=
DynamicPropertyMapWrap
<
double
,
graph_traits
<
multigraph_t
>::
vertex_descriptor
>
(
pmap
);
}
catch
(
property_not_found
)
{
throw
GraphException
(
"property "
+
property
+
" not found"
);
}
try
{
dynamic_property_map
&
pmap
=
find_property_map
(
_properties
,
property
,
typeid
(
graph_traits
<
multigraph_t
>::
vertex_descriptor
));
if
(
get_static_property_map
<
vector_property_map
<
double
,
vertex_index_map_t
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
vector_property_map
<
double
,
vertex_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
double
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
double
>
>
(
pmap
);
else
if
(
get_static_property_map
<
vector_property_map
<
size_t
,
vertex_index_map_t
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
vector_property_map
<
size_t
,
vertex_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
size_t
>
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
vertex_index_map_t
,
size_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
vertex_index_map_t
>
(
&
pmap
))
_vertex_filter_map
=
get_static_property_map
<
vertex_index_map_t
>
(
pmap
);
else
_vertex_filter_map
=
DynamicPropertyMapWrap
<
double
,
graph_traits
<
multigraph_t
>::
vertex_descriptor
>
(
pmap
);
}
catch
(
property_not_found
)
{
throw
GraphException
(
"property "
+
property
+
" not found"
);
}
}
}
...
...
@@ -127,27 +127,27 @@ void GraphInterface::SetEdgeFilterProperty(string property)
if
(
property
!=
""
)
{
try
{
dynamic_property_map
&
pmap
=
find_property_map
(
_properties
,
property
,
typeid
(
graph_traits
<
multigraph_t
>::
edge_descriptor
));
if
(
get_static_property_map
<
vector_property_map
<
double
,
edge_index_map_t
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
vector_property_map
<
double
,
edge_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
double
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
double
>
>
(
pmap
);
else
if
(
get_static_property_map
<
vector_property_map
<
size_t
,
edge_index_map_t
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
vector_property_map
<
size_t
,
edge_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
edge_index_map_t
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
edge_index_map_t
>
(
pmap
);
else
_edge_filter_map
=
DynamicPropertyMapWrap
<
double
,
graph_traits
<
multigraph_t
>::
edge_descriptor
>
(
pmap
);
}
catch
(
property_not_found
)
{
throw
GraphException
(
"property "
+
property
+
" not found"
);
}
try
{
dynamic_property_map
&
pmap
=
find_property_map
(
_properties
,
property
,
typeid
(
graph_traits
<
multigraph_t
>::
edge_descriptor
));
if
(
get_static_property_map
<
vector_property_map
<
double
,
edge_index_map_t
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
vector_property_map
<
double
,
edge_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
double
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
double
>
>
(
pmap
);
else
if
(
get_static_property_map
<
vector_property_map
<
size_t
,
edge_index_map_t
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
vector_property_map
<
size_t
,
edge_index_map_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
>
(
pmap
);
else
if
(
get_static_property_map
<
edge_index_map_t
>
(
&
pmap
))
_edge_filter_map
=
get_static_property_map
<
edge_index_map_t
>
(
pmap
);
else
_edge_filter_map
=
DynamicPropertyMapWrap
<
double
,
graph_traits
<
multigraph_t
>::
edge_descriptor
>
(
pmap
);
}
catch
(
property_not_found
)
{
throw
GraphException
(
"property "
+
property
+
" not found"
);
}
}
}
...
...
@@ -161,7 +161,7 @@ size_t GraphInterface::GetNumberOfVertices() const
{
size_t
n
=
0
;
if
(
IsVertexFilterActive
())
check_filter
(
*
this
,
var
(
n
)
=
bind
<
size_t
>
(
HardNumVertices
(),
_1
),
reverse_check
(),
directed_check
());
check_filter
(
*
this
,
var
(
n
)
=
bind
<
size_t
>
(
HardNumVertices
(),
_1
),
reverse_check
(),
directed_check
());
else
check_filter
(
*
this
,
var
(
n
)
=
bind
<
size_t
>
(
SoftNumVertices
(),
_1
),
reverse_check
(),
directed_check
());
return
n
;
...
...
@@ -174,7 +174,7 @@ size_t GraphInterface::GetNumberOfEdges() const
{
size_t
n
=
0
;
if
(
IsEdgeFilterActive
()
||
IsVertexFilterActive
())
check_filter
(
*
this
,
var
(
n
)
=
bind
<
size_t
>
(
HardNumEdges
(),
_1
),
reverse_check
(),
directed_check
());
check_filter
(
*
this
,
var
(
n
)
=
bind
<
size_t
>
(
HardNumEdges
(),
_1
),
reverse_check
(),
directed_check
());
else
check_filter
(
*
this
,
var
(
n
)
=
bind
<
size_t
>
(
SoftNumEdges
(),
_1
),
reverse_check
(),
directed_check
());
return
n
;
...
...
@@ -191,7 +191,7 @@ struct get_vertex_histogram
template
<
class
Graph
,
class
Hist
>
void
operator
()(
const
Graph
&
g
,
Hist
&
hist
)
const
{
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_begin
,
v_end
;
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_begin
,
v_end
;
tie
(
v_begin
,
v_end
)
=
vertices
(
g
);
for
(
v
=
v_begin
;
v
!=
v_end
;
++
v
)
hist
[
_degree
(
*
v
,
g
)]
++
;
...
...
@@ -202,18 +202,18 @@ struct get_vertex_histogram
struct
choose_vertex_histogram
{
choose_vertex_histogram
(
const
GraphInterface
&
g
,
GraphInterface
::
deg_t
deg
,
GraphInterface
::
hist_t
&
hist
)
:
_g
(
g
),
_hist
(
hist
)
:
_g
(
g
),
_hist
(
hist
)
{
tie
(
_deg
,
_deg_name
)
=
get_degree_type
(
deg
);
tie
(
_deg
,
_deg_name
)
=
get_degree_type
(
deg
);
}
template
<
class
DegreeSelector
>
void
operator
()(
DegreeSelector
)
{
if
(
mpl
::
at
<
degree_selector_index
,
DegreeSelector
>::
type
::
value
==
_deg
)
{
DegreeSelector
selector
(
_deg_name
,
_g
);
check_filter
(
_g
,
bind
<
void
>
(
get_vertex_histogram
<
DegreeSelector
>
(
selector
),
_1
,
var
(
_hist
)),
reverse_check
(),
directed_check
());
}
if
(
mpl
::
at
<
degree_selector_index
,
DegreeSelector
>::
type
::
value
==
_deg
)
{
DegreeSelector
selector
(
_deg_name
,
_g
);
check_filter
(
_g
,
bind
<
void
>
(
get_vertex_histogram
<
DegreeSelector
>
(
selector
),
_1
,
var
(
_hist
)),
reverse_check
(),
directed_check
());
}
}
const
GraphInterface
&
_g
;
GraphInterface
::
hist_t
&
_hist
;
...
...
@@ -229,11 +229,11 @@ GraphInterface::hist_t GraphInterface::GetVertexHistogram(GraphInterface::deg_t
hist_t
hist
;
try
{
mpl
::
for_each
<
mpl
::
vector
<
in_degreeS
,
out_degreeS
,
total_degreeS
,
scalarS
>
>
(
choose_vertex_histogram
(
*
this
,
deg
,
hist
));
mpl
::
for_each
<
mpl
::
vector
<
in_degreeS
,
out_degreeS
,
total_degreeS
,
scalarS
>
>
(
choose_vertex_histogram
(
*
this
,
deg
,
hist
));
}
catch
(
dynamic_get_failure
&
e
)
{
throw
GraphException
(
"error getting scalar property: "
+
string
(
e
.
what
()));
throw
GraphException
(
"error getting scalar property: "
+
string
(
e
.
what
()));
}
return
hist
;
...
...
@@ -249,7 +249,7 @@ struct get_edge_histogram
template
<
class
Graph
,
class
Hist
>
void
operator
()(
const
Graph
&
g
,
Hist
&
hist
)
const
{
typename
graph_traits
<
Graph
>::
edge_iterator
e
,
e_begin
,
e_end
;
typename
graph_traits
<
Graph
>::
edge_iterator
e
,
e_begin
,
e_end
;
tie
(
e_begin
,
e_end
)
=
edges
(
g
);
for
(
e
=
e_begin
;
e
!=
e_end
;
++
e
)
hist
[
_prop
(
*
e
,
g
)]
++
;
...
...
@@ -265,12 +265,12 @@ GraphInterface::hist_t GraphInterface::GetEdgeHistogram(string property) const
hist_t
hist
;
try
{
scalarS
prop
(
property
,
*
this
);
check_filter
(
*
this
,
bind
<
void
>
(
get_edge_histogram
(
prop
),
_1
,
var
(
hist
)),
reverse_check
(),
directed_check
());
scalarS
prop
(
property
,
*
this
);
check_filter
(
*
this
,
bind
<
void
>
(
get_edge_histogram
(
prop
),
_1
,
var
(
hist
)),
reverse_check
(),
directed_check
());
}
catch
(
dynamic_get_failure
&
e
)
{
throw
GraphException
(
"error getting scalar property: "
+
string
(
e
.
what
()));
throw
GraphException
(
"error getting scalar property: "
+
string
(
e
.
what
()));
}
...
...
@@ -286,19 +286,19 @@ struct label_components
template
<
class
Graph
,
class
CompMap
>
void
operator
()(
const
Graph
&
g
,
CompMap
comp_map
)
const
{
get_components
(
g
,
comp_map
,
typename
is_convertible
<
typename
graph_traits
<
Graph
>::
directed_category
,
directed_tag
>::
type
());
get_components
(
g
,
comp_map
,
typename
is_convertible
<
typename
graph_traits
<
Graph
>::
directed_category
,
directed_tag
>::
type
());
}
template
<
class
Graph
,
class
CompMap
>
void
get_components
(
const
Graph
&
g
,
CompMap
comp_map
,
boost
::
true_type
is_directed
)
const
{
strong_components
(
g
,
comp_map
);
strong_components
(
g
,
comp_map
);
}
template
<
class
Graph
,
class
CompMap
>
void
get_components
(
const
Graph
&
g
,
CompMap
comp_map
,
boost
::
false_type
is_directed
)
const
{
connected_components
(
g
,
comp_map
);
connected_components
(
g
,
comp_map
);
}
};
...
...
@@ -312,8 +312,8 @@ void GraphInterface::LabelComponents(string prop)
try
{
find_property_map
(
_properties
,
prop
,
typeid
(
graph_traits
<
multigraph_t
>::
vertex_descriptor
));
RemoveVertexProperty
(
prop
);
find_property_map
(
_properties
,
prop
,
typeid
(
graph_traits
<
multigraph_t
>::
vertex_descriptor
));
RemoveVertexProperty
(
prop
);
}
catch
(
property_not_found
)
{}
...
...
@@ -329,25 +329,25 @@ struct label_parallel_edges
template
<
class
Graph
,
class
EdgeIndexMap
,
class
ParallelMap
>
void
operator
()(
const
Graph
&
g
,
EdgeIndexMap
edge_index
,
ParallelMap
parallel
)
const
{
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_end
;
for
(
tie
(
v
,
v_end
)
=
vertices
(
g
);
v
!=
v_end
;
++
v
)
{
tr1
::
unordered_set
<
typename
graph_traits
<
Graph
>::
edge_descriptor
,
DescriptorHash
<
EdgeIndexMap
>
>
p_edges
(
0
,
DescriptorHash
<
EdgeIndexMap
>
(
edge_index
));
typename
graph_traits
<
Graph
>::
out_edge_iterator
e1
,
e2
,
e_end
;
for
(
tie
(
e1
,
e_end
)
=
out_edges
(
*
v
,
g
);
e1
!=
e_end
;
++
e1
)
{
if
(
p_edges
.
find
(
*
e1
)
!=
p_edges
.
end
())
continue
;
size_t
n
=
0
;
put
(
parallel
,
*
e1
,
n
);
for
(
tie
(
e2
,
e_end
)
=
out_edges
(
*
v
,
g
);
e2
!=
e_end
;
++
e2
)
if
(
*
e2
!=
*
e1
&&
target
(
*
e1
,
g
)
==
target
(
*
e2
,
g
))
{
put
(
parallel
,
*
e2
,
++
n
);
p_edges
.
insert
(
*
e2
);
}
}
}
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_end
;
for
(
tie
(
v
,
v_end
)
=
vertices
(
g
);
v
!=
v_end
;
++
v
)
{
tr1
::
unordered_set
<
typename
graph_traits
<
Graph
>::
edge_descriptor
,
DescriptorHash
<
EdgeIndexMap
>
>
p_edges
(
0
,
DescriptorHash
<
EdgeIndexMap
>
(
edge_index
));
typename
graph_traits
<
Graph
>::
out_edge_iterator
e1
,
e2
,
e_end
;
for
(
tie
(
e1
,
e_end
)
=
out_edges
(
*
v
,
g
);
e1
!=
e_end
;
++
e1
)
{
if
(
p_edges
.
find
(
*
e1
)
!=
p_edges
.
end
())
continue
;
size_t
n
=
0
;
put
(
parallel
,
*
e1
,
n
);
for
(
tie
(
e2
,
e_end
)
=
out_edges
(
*
v
,
g
);
e2
!=
e_end
;
++
e2
)
if
(
*
e2
!=
*
e1
&&
target
(
*
e1
,
g
)
==
target
(
*
e2
,
g
))
{
put
(
parallel
,
*
e2
,
++
n
);
p_edges
.
insert
(
*
e2
);
}
}
}
}
};
...
...
@@ -358,15 +358,15 @@ void GraphInterface::LabelParallelEdges(string property)
{
try
{
DynamicPropertyMapWrap
<
size_t
,
graph_traits
<
multigraph_t
>::
edge_descriptor
>
parallel_map
(
find_property_map
(
_properties
,
property
,
typeid
(
graph_traits
<
multigraph_t
>::
edge_descriptor
)));
check_filter
(
*
this
,
bind
<
void
>
(
label_parallel_edges
(),
_1
,
_edge_index
,
parallel_map
),
reverse_check
(),
directed_check
());
DynamicPropertyMapWrap
<
size_t
,
graph_traits
<
multigraph_t
>::
edge_descriptor
>
parallel_map
(
find_property_map
(
_properties
,
property
,
typeid
(
graph_traits
<
multigraph_t
>::
edge_descriptor
)));
check_filter
(
*
this
,
bind
<
void
>
(
label_parallel_edges
(),
_1
,
_edge_index
,
parallel_map
),
reverse_check
(),
directed_check
());
}
catch
(
property_not_found
)
{
typedef
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
parallel_map_t
;
parallel_map_t
parallel_map
(
_edge_index
);
check_filter
(
*
this
,
bind
<
void
>
(
label_parallel_edges
(),
_1
,
_edge_index
,
parallel_map
),
reverse_check
(),
directed_check
());
_properties
.
property
(
property
,
parallel_map
);
typedef
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
parallel_map_t
;
parallel_map_t
parallel_map
(
_edge_index
);
check_filter
(
*
this
,
bind
<
void
>
(
label_parallel_edges
(),
_1
,
_edge_index
,
parallel_map
),
reverse_check
(),
directed_check
());
_properties
.
property
(
property
,
parallel_map
);
}
}
...
...
@@ -396,24 +396,24 @@ struct compute_gursoy
template
<
class
Graph
,
class
PosMap
,
class
IndexMap
>
void
operator
()(
Graph
&
g
,
size_t
iter
,
size_t
seed
,
PosMap
pos
,
IndexMap
index_map
)
const
{
mt19937
rng
(
static_cast
<
mt19937
::
result_type
>
(
seed
));
size_t
n
=
HardNumVertices
()(
g
);
vector_property_map
<
square_topology
<
mt19937
>::
point_type
,
IndexMap
>
position_map
(
index_map
);
if
(
iter
==
0
)
iter
=
n
;
square_topology
<
mt19937
>
topology
(
rng
,
n
);
gursoy_atun_layout
(
g
,
topology
,
position_map
,
iterations
(
iter
).
diameter_range
(
make_pair
(
sqrt
(
double
(
n
)),
1.0
)).
learning_constant_range
(
make_pair
(
0.8
,
0.2
)).
vertex_index_map
(
index_map
));
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_begin
,
v_end
;
tie
(
v_begin
,
v_end
)
=
vertices
(
g
);
for
(
v
=
v_begin
;
v
!=
v_end
;
++
v
)
{
pos
[
*
v
].
x
=
position_map
[
*
v
][
0
];
pos
[
*
v
].
y
=
position_map
[
*
v
][
1
];
}
mt19937
rng
(
static_cast
<
mt19937
::
result_type
>
(
seed
));
size_t
n
=
HardNumVertices
()(
g
);
vector_property_map
<
square_topology
<
mt19937
>::
point_type
,
IndexMap
>
position_map
(
index_map
);
if
(
iter
==
0
)
iter
=
n
;
square_topology
<
mt19937
>
topology
(
rng
,
n
);
gursoy_atun_layout
(
g
,
topology
,
position_map
,
iterations
(
iter
).
diameter_range
(
make_pair
(
sqrt
(
double
(
n
)),
1.0
)).
learning_constant_range
(
make_pair
(
0.8
,
0.2
)).
vertex_index_map
(
index_map
));
typename
graph_traits
<
Graph
>::
vertex_iterator
v
,
v_begin
,
v_end
;
tie
(
v_begin
,
v_end
)
=
vertices
(
g
);
for
(
v
=
v_begin
;
v
!=
v_end
;
++
v
)
{
pos
[
*
v
].
x
=
position_map
[
*
v
][
0
];
pos
[
*
v
].
y
=
position_map
[
*
v
][
1
];
}
}
};
...
...
@@ -442,8 +442,8 @@ struct compute_spring_block
void
operator
()(
Graph
&
g
,
size_t
iter
,
size_t
seed
,
PosMap
pos
,
IndexMap
index_map
)
const
{
mt19937
rng
(
static_cast
<
mt19937
::
result_type
>
(
seed
));
size_t
n
=
HardNumVertices
()(
g
);
mt19937
rng
(
static_cast
<
mt19937
::
result_type
>
(
seed
));
size_t
n
=
HardNumVertices
()(
g
);
if
(
iter
==
0
)
iter
=
100
;
...
...
src/graph/graph.hh
View file @
6b764b67
...
...
@@ -46,10 +46,10 @@ public:
enum
degree_t
{
IN_DEGREE
,
OUT_DEGREE
,
TOTAL_DEGREE
,
SCALAR
IN_DEGREE
,
OUT_DEGREE
,
TOTAL_DEGREE
,
SCALAR
};
// histogram types
...
...
@@ -101,9 +101,9 @@ public:
// community structure
enum
comm_corr_t
{
ERDOS_REYNI
,
UNCORRELATED
,
CORRELATED
ERDOS_REYNI
,
UNCORRELATED
,
CORRELATED
};
void
GetCommunityStructure
(
double
gamma
,
comm_corr_t
corr
,
size_t
n_iter
,
double
Tmin
,
double
Tmax
,
size_t
Nseeds
,
size_t
seed
,
bool
verbose
,
std
::
string
history_file
,
std
::
string
weight
,
std
::
string
property
);
...
...
@@ -190,11 +190,11 @@ private:
// vertex filter
std
::
string
_vertex_filter_property
;
typedef
boost
::
variant
<
boost
::
vector_property_map
<
double
,
vertex_index_map_t
>
,
HashedDescriptorMap
<
vertex_index_map_t
,
double
>
,
boost
::
vector_property_map
<
size_t
,
vertex_index_map_t
>
,
HashedDescriptorMap
<
vertex_index_map_t
,
size_t
>
,
vertex_index_map_t
,
DynamicPropertyMapWrap
<
double
,
boost
::
graph_traits
<
multigraph_t
>::
vertex_descriptor
>
>
vertex_filter_map_t
;
HashedDescriptorMap
<
vertex_index_map_t
,
double
>
,
boost
::
vector_property_map
<
size_t
,
vertex_index_map_t
>
,
HashedDescriptorMap
<
vertex_index_map_t
,
size_t
>
,
vertex_index_map_t
,
DynamicPropertyMapWrap
<
double
,
boost
::
graph_traits
<
multigraph_t
>::
vertex_descriptor
>
>
vertex_filter_map_t
;
vertex_filter_map_t
_vertex_filter_map
;
std
::
pair
<
double
,
double
>
_vertex_range
;
boost
::
python
::
object
_vertex_python_filter
;
...
...
@@ -202,11 +202,11 @@ private:
// edge filter
std
::
string
_edge_filter_property
;
typedef
boost
::
variant
<
boost
::
vector_property_map
<
double
,
edge_index_map_t
>
,
HashedDescriptorMap
<
edge_index_map_t
,
double
>
,
boost
::
vector_property_map
<
size_t
,
edge_index_map_t
>
,
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
,
edge_index_map_t
,
DynamicPropertyMapWrap
<
double
,
boost
::
graph_traits
<
multigraph_t
>::
edge_descriptor
>
>
edge_filter_map_t
;
HashedDescriptorMap
<
edge_index_map_t
,
double
>
,
boost
::
vector_property_map
<
size_t
,
edge_index_map_t
>
,
HashedDescriptorMap
<
edge_index_map_t
,
size_t
>
,
edge_index_map_t
,
DynamicPropertyMapWrap
<
double
,
boost
::
graph_traits
<
multigraph_t
>::
edge_descriptor
>
>
edge_filter_map_t
;
edge_filter_map_t
_edge_filter_map
;
std
::
pair
<
double
,
double
>
_edge_range
;
boost
::
python
::
object
_edge_python_filter
;
...
...
src/graph/graph_adaptor.hh
View file @
6b764b67
...
...
@@ -111,10 +111,10 @@ private:
template
<
typename
Graph
>
class
UndirectedAdaptorEdgeIterator
:
public
iterator
<
std
::
bidirectional_iterator_tag
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
,
std
::
ptrdiff_t
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
*
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
>
//not a reference!
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
,
std
::
ptrdiff_t
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
*
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
>
//not a reference!
{
public:
UndirectedAdaptorEdgeIterator
()
{}
...
...
@@ -174,19 +174,19 @@ private:
template
<
typename
Graph
>
class
UndirectedAdaptorOutEdgeIterator
:
public
iterator
<
std
::
bidirectional_iterator_tag
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
,
std
::
ptrdiff_t
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
*
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
>
//not a reference
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
,
std
::
ptrdiff_t
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
*
,
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
>
//not a reference
{
public:
UndirectedAdaptorOutEdgeIterator
()
{};
UndirectedAdaptorOutEdgeIterator
(
typename
graph_traits
<
Graph
>::
out_edge_iterator
out_iter
,
typename
graph_traits
<
Graph
>::
in_edge_iterator
in_iter
,
const
std
::
pair
<
typename
graph_traits
<
Graph
>::
out_edge_iterator
,
typename
graph_traits
<
Graph
>::
out_edge_iterator
>
out_range
,
const
std
::
pair
<
typename
graph_traits
<
Graph
>::
in_edge_iterator
,
typename
graph_traits
<
Graph
>::
in_edge_iterator
>
in_range
)
typename
graph_traits
<
Graph
>::
in_edge_iterator
in_iter
,
const
std
::
pair
<
typename
graph_traits
<
Graph
>::
out_edge_iterator
,
typename
graph_traits
<
Graph
>::
out_edge_iterator
>
out_range
,
const
std
::
pair
<
typename
graph_traits
<
Graph
>::
in_edge_iterator
,
typename
graph_traits
<
Graph
>::
in_edge_iterator
>
in_range
)
:
_out_range
(
out_range
),
_in_range
(
in_range
),
_out_iter
(
out_iter
),
_in_iter
(
in_iter
)
{};
typename
UndirectedAdaptor
<
Graph
>::
EdgeDescriptor
operator
*
()
const
...
...
@@ -280,10 +280,10 @@ public:
template
<
typename
Graph
>
class
UndirectedAdaptorAdjacencyIterator
:
public
iterator
<
std
::
bidirectional_iterator_tag
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
,
std
::
ptrdiff_t
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
*
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
>
//not a reference
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
,
std
::
ptrdiff_t
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
*
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
>
//not a reference
{
public:
UndirectedAdaptorAdjacencyIterator
(){};
...
...
@@ -570,7 +570,7 @@ void remove_vertex(typename graph_traits< UndirectedAdaptor<Graph> >::vertex_des
template
<
class
Graph
>
std
::
pair
<
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
edge_descriptor
,
bool
>
add_edge
(
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
u
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
v
,
UndirectedAdaptor
<
Graph
>&
g
)
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
v
,
UndirectedAdaptor
<
Graph
>&
g
)
{
std
::
pair
<
typename
graph_traits
<
Graph
>::
edge_descriptor
,
bool
>
retval
=
add_edge
(
u
,
v
,
g
.
OriginalGraph
());
return
std
::
make_pair
(
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
edge_descriptor
(
retval
.
first
,
false
),
retval
.
second
);
...
...
@@ -582,7 +582,7 @@ add_edge(typename graph_traits< UndirectedAdaptor<Graph> >::vertex_descriptor u,
template
<
class
Graph
,
class
EdgeProperties
>
std
::
pair
<
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
edge_descriptor
,
bool
>
add_edge
(
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
u
,
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
v
,
const
EdgeProperties
&
ep
,
UndirectedAdaptor
<
Graph
>&
g
)
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
vertex_descriptor
v
,
const
EdgeProperties
&
ep
,
UndirectedAdaptor
<
Graph
>&
g
)
{
std
::
pair
<
typename
graph_traits
<
Graph
>::
edge_descriptor
,
bool
>
retval
=
add_edge
(
u
,
v
,
ep
,
g
.
OriginalGraph
());
return
std
::
make_pair
(
typename
graph_traits
<
UndirectedAdaptor
<
Graph
>
>::
edge_descriptor
(
retval
.
first
,
false
),
retval
.
second
);
...
...
src/graph/graph_assortativity.cc
View file @
6b764b67
...
...
@@ -45,60 +45,60 @@ struct get_assortativity_coefficient
template
<
class
Graph
>
void
operator
()(
const
Graph
&
g
,
double
&
r
,
double
&
r_err
)
const
{
size_t
n_edges
=
0
;
int
e_kk
=
0
;
tr1
::
unordered_map
<
double
,
int
>
a
,
b
;
typename
graph_traits
<
Graph
>::
edge_iterator
e
,
e_begin
,
e_end
;
tie
(
e_begin
,
e_end
)
=
edges
(
g
);
for
(
e
=
e_begin
;
e
!=
e_end
;
++
e
)
{
double
k1
,
k2
;
k1
=
_deg
(
source
(
*
e
,
g
),
g
);
k2
=
_deg
(
target
(
*
e
,
g
),
g
);
a
[
k1
]
++
;
b
[
k2
]
++
;
if
(
k1
==
k2
)
e_kk
++
;
n_edges
++
;
if
(
is_convertible
<
typename
graph_traits
<
Graph
>::
directed_category
,
undirected_tag
>::
value
)
{
a
[
k2
]
++
;
a
[
k1
]
++
;
if
(
k1
==
k2
)
e_kk
++
;
n_edges
++
;
}
}
double
t1
=
double
(
e_kk
)
/
n_edges
,
t2
=
0.0
;
for
(
typeof
(
a
.
begin
())
iter
=
a
.
begin
();
iter
!=
a
.
end
();
++
iter
)
if
(
b
.
find
(
iter
->
second
)
!=
b
.
end
())
t2
+=
double
(
iter
->
second
*
b
[
iter
->
first
]);
t2
/=
n_edges
*
n_edges
;
r
=
(
t1
-
t2
)
/
(
1.0
-
t2
);
size_t
n_edges
=
0
;
int
e_kk
=
0
;
tr1
::
unordered_map
<
double
,
int
>
a
,
b
;
typename
graph_traits
<
Graph
>::
edge_iterator
e
,
e_begin
,
e_end
;
tie
(
e_begin
,
e_end
)
=
edges
(
g
);
for
(
e
=
e_begin
;
e
!=
e_end
;
++
e
)
{
double
k1
,
k2
;
k1
=
_deg
(
source
(
*
e
,
g
),
g
);
k2
=
_deg
(
target
(
*
e
,
g
),
g
);
a
[
k1
]
++
;
b
[
k2
]
++
;
if
(
k1
==
k2
)