Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_io
Commits
417942d4
Commit
417942d4
authored
10 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
Fixed GraphML compilation
parent
d2a7fbed
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/GraphMLWriter.hpp
+42
-32
42 additions, 32 deletions
src/GraphMLWriter.hpp
with
42 additions
and
32 deletions
src/GraphMLWriter.hpp
+
42
−
32
View file @
417942d4
...
...
@@ -7,6 +7,16 @@
#include
<boost/fusion/include/for_each.hpp>
#include
<fstream>
namespace
std
{
// We need the definition of std::to_string that work on string
std
::
string
to_string
(
std
::
string
s
)
{
return
s
;
}
}
/*! \brief this class is a functor for "for_each" algorithm
*
* This class is a functor for "for_each" algorithm. For each
...
...
@@ -68,23 +78,23 @@ struct vertex_prop
if
(
cnt
<
n_attr
)
{
// if it is a yFile extension property name, does not process it
if
(
attributes_names
[
t
]
==
"x"
||
attributes_names
[
t
]
==
"y"
||
attributes_names
[
t
]
==
"z"
||
attributes_names
[
t
]
==
"shape"
)
if
(
attributes_names
[
cn
t
]
==
"x"
||
attributes_names
[
cn
t
]
==
"y"
||
attributes_names
[
cn
t
]
==
"z"
||
attributes_names
[
cn
t
]
==
"shape"
)
{
cnt
++
;
return
;}
// Create a property string based on the type of the property
if
(
typeid
(
T
)
==
typeid
(
float
))
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
float
\"
/>"
;
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
float
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
double
))
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
double
\"
/>"
;
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
double
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
int
))
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
int
\"
/>"
;
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
int
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
long
int
))
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
long
\"
/>"
;
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
long
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
bool
))
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
boolean
\"
/>"
;
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
boolean
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
std
::
string
))
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
string
\"
/>"
;
v_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
string
\"
/>"
;
}
cnt
++
;
...
...
@@ -275,7 +285,7 @@ struct edge_prop
* \param n_prop number of properties
*
*/
edge_prop
(
std
::
string
&
v
_prop
)
edge_prop
(
std
::
string
&
e
_prop
)
:
e_prop
(
e_prop
),
attributes_names
(
NULL
)
{
};
...
...
@@ -288,23 +298,23 @@ struct edge_prop
if
(
cnt
<
n_attr
)
{
// if it is a yFile extension property name, does not process it
if
(
attributes_names
[
t
]
==
"x"
||
attributes_names
[
t
]
==
"y"
||
attributes_names
[
t
]
==
"z"
||
attributes_names
[
t
]
==
"shape"
)
if
(
attributes_names
[
cn
t
]
==
"x"
||
attributes_names
[
cn
t
]
==
"y"
||
attributes_names
[
cn
t
]
==
"z"
||
attributes_names
[
cn
t
]
==
"shape"
)
{
cnt
++
;
return
;}
// Create a property string based on the type of the property
if
(
typeid
(
T
)
==
typeid
(
float
))
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
float
\"
/>"
;
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
float
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
double
))
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
double
\"
/>"
;
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
double
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
int
))
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
int
\"
/>"
;
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
int
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
long
int
))
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
long
\"
/>"
;
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
long
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
bool
))
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
boolean
\"
/>"
;
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
boolean
\"
/>"
;
else
if
(
typeid
(
T
)
==
typeid
(
std
::
string
))
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
t
]
+
" attr.type=
\"
string
\"
/>"
;
e_prop
+=
"<key id=
\"
v"
+
std
::
to_string
(
cnt
)
+
"
\"
for=
\"
node
\"
attr.name="
+
attributes_names
[
cn
t
]
+
" attr.type=
\"
string
\"
/>"
;
}
cnt
++
;
...
...
@@ -373,7 +383,7 @@ struct edge_node
* \param n_prop number of properties
*
*/
edge_node
(
std
::
string
&
v_node
,
const
typename
G
::
V
_container
&
n_obj
)
edge_node
(
std
::
string
&
v_node
,
const
typename
G
::
E
_container
&
n_obj
)
:
vo
(
n_obj
),
e_node
(
e_node
),
attributes_names
(
NULL
)
{
};
...
...
@@ -406,7 +416,7 @@ struct edge_node
void
end_node
()
{
// close a node
v
_node
+=
"</node>"
;
e
_node
+=
"</node>"
;
}
//! It call the functor for each member
...
...
@@ -429,17 +439,17 @@ struct edge_node
{
// Create a property string based on the type of the property
if
(
typeid
(
decltype
(
vo
.
template
get
<
T
::
value
>()))
==
typeid
(
float
))
v
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
e
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
else
if
(
typeid
(
decltype
(
vo
.
template
get
<
T
::
value
>()))
==
typeid
(
double
))
v
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
e
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
else
if
(
typeid
(
decltype
(
vo
.
template
get
<
T
::
value
>()))
==
typeid
(
int
))
v
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
e
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
else
if
(
typeid
(
decltype
(
vo
.
template
get
<
T
::
value
>()))
==
typeid
(
long
int
))
v
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
e
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
else
if
(
typeid
(
decltype
(
vo
.
template
get
<
T
::
value
>()))
==
typeid
(
bool
))
v
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
e
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
else
if
(
typeid
(
decltype
(
vo
.
template
get
<
T
::
value
>()))
==
typeid
(
std
::
string
))
v
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
e
_node
+=
"<data key=
\"
key"
+
std
::
to_string
(
cnt
)
+
"
\"
>"
+
std
::
to_string
(
vo
.
template
get
<
T
::
value
>())
+
"</>"
;
}
}
...
...
@@ -496,16 +506,16 @@ class GraphMLWriter
std
::
string
get_edge_properties_list
()
{
//! edge property output string
std
::
string
v
_out
;
std
::
string
e
_out
(
" "
)
;
// create a vertex property functor
edge_prop
<
Graph
>
v
p
(
v
_out
);
edge_prop
<
Graph
>
e
p
(
e
_out
);
// Iterate through all the vertex and create the vertex list
boost
::
mpl
::
for_each
<
typename
Graph
::
E_type
::
type
>
(
v
p
);
boost
::
mpl
::
for_each
<
typename
Graph
::
E_type
::
type
>
(
e
p
);
// return the edge properties string
return
v
_out
;
return
e
_out
;
}
std
::
string
get_vertex_list
()
...
...
@@ -523,7 +533,7 @@ class GraphMLWriter
vertex_node
<
Graph
>
vn
(
v_out
,
g
.
vertex
(
it
.
get
()));
// Iterate through all the vertex and create the vertex list
boost
::
mpl
::
for_each
<
typename
Graph
::
V_type
::
type
>
(
vn
);
boost
::
mpl
::
for_each
<
boost
::
mpl
::
range_c
<
int
,
0
,
Graph
::
V_type
::
max_prop
-
1
>
>
(
vn
);
// increment the operator
++
it
;
...
...
@@ -545,10 +555,10 @@ class GraphMLWriter
while
(
it
.
isNext
())
{
// create an edge list functor
edge_node
<
Graph
>
en
(
v_out
,
g
.
edge
(
it
));
edge_node
<
Graph
>
en
(
v_out
,
g
.
edge
(
it
.
get
()
));
// Iterate through all the vertex and create the vertex list
boost
::
mpl
::
for_each
<
typename
Graph
::
E
_type
::
type
>
(
en
);
boost
::
mpl
::
for_each
<
boost
::
mpl
::
range_c
<
int
,
0
,
Graph
::
V
_type
::
max_prop
-
1
>
>
(
en
);
// increment the operator
++
it
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment