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
7cdf9658
Commit
7cdf9658
authored
Dec 02, 2008
by
Tiago Peixoto
Browse files
Expose internal graph and index maps in GraphInterface
This makes operations on graphs more flexible in some circumstances.
parent
c153e0c0
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/graph/graph.hh
View file @
7cdf9658
...
...
@@ -147,9 +147,12 @@ public:
typedef
property_map
<
multigraph_t
,
edge_index_t
>::
type
edge_index_map_t
;
typedef
ConstantPropertyMap
<
size_t
,
graph_property_tag
>
graph_index_map_t
;
boost
::
any
GetVertexIndex
()
{
return
_vertex_index
;}
boost
::
any
GetEdgeIndex
()
{
return
_edge_index
;}
boost
::
any
GetGraphIndex
()
{
return
graph_index_map_t
(
0
);}
// internal access
multigraph_t
&
GetGraph
()
{
return
_mg
;}
vertex_index_map_t
GetVertexIndex
()
{
return
_vertex_index
;}
edge_index_map_t
GetEdgeIndex
()
{
return
_edge_index
;}
graph_index_map_t
GetGraphIndex
()
{
return
graph_index_map_t
(
0
);}
private:
// Gets the encapsulated graph view. See graph_filtering.cc for details
...
...
src/graph/graph_bind.cc
View file @
7cdf9658
...
...
@@ -322,6 +322,10 @@ BOOST_PYTHON_MODULE(libgraph_tool_core)
.
def
(
"CopyVertexProperty"
,
&
GraphInterface
::
CopyVertexProperty
)
.
def
(
"CopyEdgeProperty"
,
&
GraphInterface
::
CopyEdgeProperty
);
class_
<
GraphInterface
::
vertex_index_map_t
>
(
"vertex_index_map"
,
no_init
);
class_
<
GraphInterface
::
edge_index_map_t
>
(
"edge_index_map"
,
no_init
);
class_
<
GraphInterface
::
graph_index_map_t
>
(
"graph_index_map"
,
no_init
);
enum_
<
GraphInterface
::
degree_t
>
(
"Degree"
)
.
value
(
"In"
,
GraphInterface
::
IN_DEGREE
)
.
value
(
"Out"
,
GraphInterface
::
OUT_DEGREE
)
...
...
src/graph/graph_python_interface.cc
View file @
7cdf9658
...
...
@@ -299,14 +299,14 @@ PythonPropertyMap<GraphInterface::vertex_index_map_t>
get_vertex_index
(
GraphInterface
&
g
)
{
return
PythonPropertyMap
<
GraphInterface
::
vertex_index_map_t
>
(
any_cast
<
GraphInterface
::
vertex_index_map_t
>
(
g
.
GetVertexIndex
())
)
;
(
g
.
GetVertexIndex
());
}
PythonPropertyMap
<
GraphInterface
::
edge_index_map_t
>
get_edge_index
(
GraphInterface
&
g
)
{
return
PythonPropertyMap
<
GraphInterface
::
edge_index_map_t
>
(
any_cast
<
GraphInterface
::
edge_index_map_t
>
(
g
.
GetEdgeIndex
())
)
;
(
g
.
GetEdgeIndex
());
}
// register everything
...
...
src/graph/graph_python_interface.hh
View file @
7cdf9658
...
...
@@ -455,17 +455,8 @@ struct new_property_map
};
template
<
class
IndexMap
>
python
::
object
new_property
(
const
string
&
type
,
boost
::
any
i
map
)
python
::
object
new_property
(
const
string
&
type
,
IndexMap
index_
map
)
{
IndexMap
index_map
;
try
{
index_map
=
any_cast
<
IndexMap
>
(
imap
);
}
catch
(
bad_any_cast
&
)
{
throw
GraphException
(
"Invalid index map"
);
}
python
::
object
prop
;
bool
found
=
false
;
mpl
::
for_each
<
value_types
>
(
lambda
::
bind
<
void
>
(
new_property_map
(),
...
...
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