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
b3dd46c3
Commit
b3dd46c3
authored
Dec 03, 2010
by
Tiago Peixoto
Browse files
Modify GraphWrap semantics
Now, whenever GraphWrap is being used, the property maps are always in "checked" mode.
parent
b50fc2fc
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/graph/flow/graph_augment.hh
View file @
b3dd46c3
...
...
@@ -78,15 +78,15 @@ void deaugment_graph(Graph& g, AugmentedMap augmented)
template
<
class
Type
,
class
Index
>
checked_vector_property_map
<
Type
,
Index
>
get_checked
(
un
checked_vector_property_map
<
Type
,
Index
>
prop
)
un
checked_vector_property_map
<
Type
,
Index
>
get_
un
checked
(
checked_vector_property_map
<
Type
,
Index
>
prop
)
{
return
prop
.
get_checked
();
return
prop
.
get_
un
checked
();
}
template
<
class
Prop
>
Prop
get_checked
(
Prop
prop
)
get_
un
checked
(
Prop
prop
)
{
return
prop
;
}
...
...
src/graph/flow/graph_edmonds_karp.cc
View file @
b3dd46c3
...
...
@@ -41,12 +41,12 @@ struct get_edmonds_karp_max_flow
augmented
(
edge_index
,
max_e
);
unchecked_vector_property_map
<
edge_t
,
EdgeIndex
>
reverse_map
(
edge_index
,
max_e
);
augment_graph
(
g
,
augmented
.
get_checked
(),
get_checked
(
cm
),
re
verse_map
.
get_checked
(),
res
.
get_checked
()
);
augment_graph
(
g
,
augmented
.
get_checked
(),
cm
,
reverse_map
.
get_checked
(),
re
s
);
boost
::
edmonds_karp_max_flow
(
g
.
_g
,
vertex
(
src
,
g
),
vertex
(
sink
,
g
),
capacity_map
(
cm
).
capacity_map
(
get_unchecked
(
cm
)
)
.
reverse_edge_map
(
reverse_map
).
residual_capacity_map
(
res
));
residual_capacity_map
(
res
.
get_unchecked
()
));
deaugment_graph
(
g
,
augmented
.
get_checked
());
}
};
...
...
src/graph/flow/graph_kolmogorov.cc
View file @
b3dd46c3
...
...
@@ -71,9 +71,10 @@ struct get_kolmogorov_max_flow
unchecked_vector_property_map
<
size_t
,
VertexIndex
>
dist_map
(
vertex_index
,
num_vertices
(
g
));
augment_graph
(
g
,
augmented
.
get_checked
(),
get_checked
(
cm
),
reverse_map
.
get_checked
(),
res
.
get_checked
());
boost
::
kolmogorov_max_flow
(
g
.
_g
,
cm
,
res
,
reverse_map
,
pred_map
,
augment_graph
(
g
,
augmented
.
get_checked
(),
cm
,
reverse_map
.
get_checked
(),
res
);
boost
::
kolmogorov_max_flow
(
g
.
_g
,
get_unchecked
(
cm
),
res
.
get_unchecked
(),
reverse_map
,
pred_map
,
color_map
,
dist_map
,
vertex_index
,
vertex
(
src
,
g
),
vertex
(
sink
,
g
));
deaugment_graph
(
g
,
augmented
.
get_checked
());
...
...
src/graph/flow/graph_push_relabel.cc
View file @
b3dd46c3
...
...
@@ -65,12 +65,12 @@ struct get_push_relabel_max_flow
augmented
(
edge_index
,
max_e
);
unchecked_vector_property_map
<
edge_t
,
EdgeIndex
>
reverse_map
(
edge_index
,
max_e
);
augment_graph
(
g
,
augmented
.
get_checked
(),
get_checked
(
cm
)
,
reverse_map
.
get_checked
(),
res
.
get_checked
()
);
augment_graph
(
g
,
augmented
.
get_checked
(),
cm
,
reverse_map
.
get_checked
(),
res
);
boost
::
push_relabel_max_flow
(
g
.
_g
,
vertex
(
src
,
g
),
vertex
(
sink
,
g
),
capacity_map
(
cm
).
capacity_map
(
get_unchecked
(
cm
)
)
.
reverse_edge_map
(
reverse_map
).
residual_capacity_map
(
res
));
residual_capacity_map
(
res
.
get_unchecked
()
));
deaugment_graph
(
g
,
augmented
.
get_checked
());
}
};
...
...
src/graph/generation/graph_union.hh
View file @
b3dd46c3
...
...
@@ -54,8 +54,7 @@ struct property_union
UnionProp
uprop
,
boost
::
any
aprop
)
const
{
Graph
&
g
=
*
gp
;
typename
UnionProp
::
checked_t
prop
=
any_cast
<
typename
UnionProp
::
checked_t
>
(
aprop
);
UnionProp
prop
=
any_cast
<
UnionProp
>
(
aprop
);
dispatch
(
ug
,
g
,
vmap
,
emap
,
uprop
,
prop
,
is_same
<
typename
property_traits
<
UnionProp
>::
key_type
,
typename
graph_traits
<
Graph
>::
vertex_descriptor
>
());
...
...
src/graph/generation/graph_union_eprop.cc
View file @
b3dd46c3
...
...
@@ -53,7 +53,7 @@ void edge_property_union(GraphInterface& ugi, GraphInterface& gi,
vprop_t
vprop
=
any_cast
<
vprop_t
>
(
p_vprop
);
eprop_t
eprop
=
any_cast
<
eprop_t
>
(
p_eprop
);
run_action
<
graph_tool
::
detail
::
always_directed
,
mpl
::
true_
>
()
run_action
<
graph_tool
::
detail
::
always_directed
>
()
(
ugi
,
bind
<
void
>
(
graph_tool
::
property_union
(),
_1
,
_2
,
vprop
,
eprop
,
_3
,
prop
),
get_pointers
::
apply
<
graph_tool
::
detail
::
always_directed
>::
type
(),
...
...
src/graph/generation/graph_union_vprop.cc
View file @
b3dd46c3
...
...
@@ -52,7 +52,7 @@ void vertex_property_union(GraphInterface& ugi, GraphInterface& gi,
vprop_t
vprop
=
any_cast
<
vprop_t
>
(
p_vprop
);
eprop_t
eprop
=
any_cast
<
eprop_t
>
(
p_eprop
);
run_action
<
graph_tool
::
detail
::
always_directed
,
mpl
::
true_
>
()
run_action
<
graph_tool
::
detail
::
always_directed
>
()
(
ugi
,
bind
<
void
>
(
graph_tool
::
property_union
(),
_1
,
_2
,
vprop
,
eprop
,
_3
,
prop
),
get_pointers
::
apply
<
graph_tool
::
detail
::
always_directed
>::
type
(),
...
...
src/graph/graph_bind.cc
View file @
b3dd46c3
...
...
@@ -307,11 +307,11 @@ string get_graph_type(GraphInterface& g)
bool
openmp_enabled
()
{
#ifdef USING_OPENMP
#ifdef USING_OPENMP
return
true
;
#else
#else
return
false
;
#endif
#endif
}
void
ungroup_vector_property
(
GraphInterface
&
g
,
boost
::
any
vector_prop
,
...
...
src/graph/graph_filtering.hh
View file @
b3dd46c3
...
...
@@ -509,33 +509,48 @@ struct action_wrap
:
_a
(
a
),
_g
(
g
),
_max_v
(
max_v
),
_max_e
(
max_e
)
{}
template
<
class
Type
>
typename
checked_vector_property_map
<
Type
,
GraphInterface
::
vertex_index_map_t
>::
unchecked_t
checked_vector_property_map
<
Type
,
GraphInterface
::
vertex_index_map_t
>
uncheck
(
checked_vector_property_map
<
Type
,
GraphInterface
::
vertex_index_map_t
>
a
)
const
<
Type
,
GraphInterface
::
vertex_index_map_t
>
a
,
mpl
::
true_
)
const
{
return
a
;
}
template
<
class
Type
>
unchecked_vector_property_map
<
Type
,
GraphInterface
::
vertex_index_map_t
>
uncheck
(
checked_vector_property_map
<
Type
,
GraphInterface
::
vertex_index_map_t
>
a
,
mpl
::
false_
)
const
{
return
a
.
get_unchecked
(
_max_v
);
}
template
<
class
Type
>
typename
checked_vector_property_map
<
Type
,
GraphInterface
::
edge_index_map_t
>::
unchecked_t
checked_vector_property_map
<
Type
,
GraphInterface
::
edge_index_map_t
>
uncheck
(
checked_vector_property_map
<
Type
,
GraphInterface
::
edge_index_map_t
>
a
)
const
<
Type
,
GraphInterface
::
edge_index_map_t
>
a
,
mpl
::
true_
)
const
{
return
a
;
}
template
<
class
Type
>
unchecked_vector_property_map
<
Type
,
GraphInterface
::
edge_index_map_t
>
uncheck
(
checked_vector_property_map
<
Type
,
GraphInterface
::
edge_index_map_t
>
a
,
mpl
::
false_
)
const
{
return
a
.
get_unchecked
(
_max_e
);
}
template
<
class
Type
>
scalarS
<
typename
Type
::
unchecked_t
>
uncheck
(
scalarS
<
Type
>
a
)
const
uncheck
(
scalarS
<
Type
>
a
,
mpl
::
false_
)
const
{
return
scalarS
<
typename
Type
::
unchecked_t
>
(
uncheck
(
a
.
_pmap
));
return
scalarS
<
typename
Type
::
unchecked_t
>
(
uncheck
(
a
.
_pmap
,
mpl
::
false_
()));
}
//no op
template
<
class
Type
>
Type
uncheck
(
Type
a
)
const
{
return
a
;
}
template
<
class
Type
,
class
DoWrap
>
Type
uncheck
(
Type
a
,
DoWrap
)
const
{
return
a
;
}
template
<
class
Graph
>
GraphWrap
<
Graph
>
wrap
(
Graph
*
g
,
mpl
::
true_
)
const
...
...
@@ -550,21 +565,24 @@ struct action_wrap
}
void
operator
()()
const
{};
template
<
class
T1
>
void
operator
()(
const
T1
&
a1
)
const
{
_a
(
wrap
(
a1
,
Wrap
()));
}
template
<
class
T1
>
void
operator
()(
const
T1
&
a1
)
const
{
_a
(
wrap
(
a1
,
Wrap
()));
}
template
<
class
T1
,
class
T2
>
void
operator
()(
const
T1
&
a1
,
const
T2
&
a2
)
const
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
));
}
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
,
Wrap
()
));
}
template
<
class
T1
,
class
T2
,
class
T3
>
void
operator
()(
const
T1
&
a1
,
const
T2
&
a2
,
const
T3
&
a3
)
const
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
),
uncheck
(
a3
));}
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
,
Wrap
()
),
uncheck
(
a3
,
Wrap
()
));}
template
<
class
T1
,
class
T2
,
class
T3
,
class
T4
>
void
operator
()(
const
T1
&
a1
,
const
T2
&
a2
,
const
T3
&
a3
,
const
T4
&
a4
)
const
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
),
uncheck
(
a3
),
uncheck
(
a4
));
}
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
,
Wrap
()),
uncheck
(
a3
,
Wrap
()),
uncheck
(
a4
,
Wrap
()));
}
template
<
class
T1
,
class
T2
,
class
T3
,
class
T4
,
class
T5
>
void
operator
()(
const
T1
&
a1
,
const
T2
&
a2
,
const
T3
&
a3
,
const
T4
&
a4
,
const
T5
&
a5
)
const
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
),
uncheck
(
a3
),
uncheck
(
a4
),
uncheck
(
a5
));
}
{
_a
(
wrap
(
a1
,
Wrap
()),
uncheck
(
a2
,
Wrap
()),
uncheck
(
a3
,
Wrap
()),
uncheck
(
a4
,
Wrap
()),
uncheck
(
a5
),
Wrap
());
}
Action
_a
;
reference_wrapper
<
GraphInterface
>
_g
;
...
...
src/graph/graph_wrap.hh
View file @
b3dd46c3
...
...
@@ -60,6 +60,17 @@ template <class Graph>
struct
graph_traits
<
const
GraphWrap
<
Graph
>
>:
public
graph_traits
<
const
Graph
>
{};
template
<
class
Graph
,
class
Tag
>
struct
property_map
<
GraphWrap
<
Graph
>
,
Tag
>:
public
property_map
<
Graph
,
Tag
>
{};
template
<
class
Graph
,
class
Tag
>
typename
property_map
<
Graph
,
Tag
>::
type
get
(
Tag
t
,
const
GraphWrap
<
Graph
>&
g
)
{
return
get
(
t
,
g
.
_g
);
}
template
<
class
Graph
>
inline
typename
graph_traits
<
GraphWrap
<
Graph
>
>::
vertex_descriptor
source
(
typename
graph_traits
<
GraphWrap
<
Graph
>
>::
edge_descriptor
e
,
...
...
Write
Preview
Supports
Markdown
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