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
df4e2faf
Commit
df4e2faf
authored
Aug 02, 2020
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve speed of GML writing
Remove uncessary exception throwing and property map checking.
parent
23228363
Pipeline
#695
passed with stage
in 61 minutes and 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
35 deletions
+36
-35
src/graph/gml.hh
src/graph/gml.hh
+36
-35
No files found.
src/graph/gml.hh
View file @
df4e2faf
...
...
@@ -390,28 +390,24 @@ struct get_str
template
<
typename
ValueType
>
void
operator
()(
const
boost
::
any
&
val
,
std
::
string
&
sval
,
ValueType
)
const
{
try
const
ValueType
*
v
=
any_cast
<
ValueType
>
(
&
val
);
if
(
v
==
nullptr
)
return
;
if
constexpr
(
std
::
is_same
<
ValueType
,
python
::
object
>::
value
)
{
ValueType
v
=
any_cast
<
ValueType
>
(
val
);
if
constexpr
(
std
::
is_same
<
ValueType
,
python
::
object
>::
value
)
{
sval
=
base64_encode
(
lexical_cast
<
string
>
(
v
));
}
else
{
stringstream
s
;
s
<<
v
;
sval
=
s
.
str
();
}
if
constexpr
(
!
std
::
is_scalar
<
ValueType
>::
value
)
{
replace_all
(
sval
,
"
\"
"
,
"
\\\"
"
);
sval
=
"
\"
"
+
sval
+
"
\"
"
;
}
sval
=
base64_encode
(
lexical_cast
<
string
>
(
*
v
));
}
catch
(
bad_any_cast
&
)
else
{
stringstream
s
;
s
<<
*
v
;
sval
=
s
.
str
();
}
if
constexpr
(
!
std
::
is_scalar
<
ValueType
>::
value
)
{
replace_all
(
sval
,
"
\"
"
,
"
\\\"
"
);
sval
=
"
\"
"
+
sval
+
"
\"
"
;
}
}
};
...
...
@@ -450,6 +446,9 @@ void write_gml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index,
if
(
graph_is_directed
)
out
<<
" directed "
<<
1
<<
endl
;
dynamic_properties
vdp
;
dynamic_properties
edp
;
for
(
auto
&
i
:
dp
)
{
if
(
i
.
second
->
key
()
==
typeid
(
graph_property_tag
))
...
...
@@ -460,6 +459,14 @@ void write_gml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index,
continue
;
out
<<
" "
<<
i
.
first
<<
" "
<<
val
<<
endl
;
}
else
if
(
i
.
second
->
key
()
==
typeid
(
vertex_descriptor
))
{
vdp
.
insert
(
i
.
first
,
i
.
second
);
}
else
if
(
i
.
second
->
key
()
==
typeid
(
edge_descriptor
))
{
edp
.
insert
(
i
.
first
,
i
.
second
);
}
}
for
(
auto
v
:
vertices_range
(
g
))
...
...
@@ -467,15 +474,12 @@ void write_gml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index,
out
<<
" node ["
<<
endl
;
out
<<
" id "
<<
get
(
vertex_index
,
v
)
<<
endl
;
for
(
auto
&
i
:
dp
)
for
(
auto
&
i
:
v
dp
)
{
if
(
i
.
second
->
key
()
==
typeid
(
vertex_descriptor
))
{
std
::
string
val
=
print_val
<
value_types
>
(
*
i
.
second
,
v
);
if
(
val
.
empty
())
continue
;
out
<<
" "
<<
i
.
first
<<
" "
<<
val
<<
endl
;
}
std
::
string
val
=
print_val
<
value_types
>
(
*
i
.
second
,
v
);
if
(
val
.
empty
())
continue
;
out
<<
" "
<<
i
.
first
<<
" "
<<
val
<<
endl
;
}
out
<<
" ]"
<<
endl
;
}
...
...
@@ -488,15 +492,12 @@ void write_gml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index,
out
<<
" source "
<<
get
(
vertex_index
,
source
(
e
,
g
))
<<
endl
;
out
<<
" target "
<<
get
(
vertex_index
,
target
(
e
,
g
))
<<
endl
;
for
(
auto
&
i
:
dp
)
for
(
auto
&
i
:
e
dp
)
{
if
(
i
.
second
->
key
()
==
typeid
(
edge_descriptor
))
{
std
::
string
val
=
print_val
<
value_types
>
(
*
i
.
second
,
e
);
if
(
val
.
empty
())
continue
;
out
<<
" "
<<
i
.
first
<<
" "
<<
val
<<
endl
;
}
std
::
string
val
=
print_val
<
value_types
>
(
*
i
.
second
,
e
);
if
(
val
.
empty
())
continue
;
out
<<
" "
<<
i
.
first
<<
" "
<<
val
<<
endl
;
}
out
<<
" ]"
<<
endl
;
}
...
...
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