Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Jakub Janák
tss
Commits
48949765
Commit
48949765
authored
3 months ago
by
Jakub Janák
Browse files
Options
Downloads
Patches
Plain Diff
file manager read dot file method was refactored
parent
dc4b57c9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
files/file_manager.cpp
+20
-15
20 additions, 15 deletions
files/file_manager.cpp
files/file_manager.hpp
+4
-0
4 additions, 0 deletions
files/file_manager.hpp
with
24 additions
and
15 deletions
files/file_manager.cpp
+
20
−
15
View file @
48949765
...
...
@@ -46,24 +46,11 @@ bool file_manager::load_graph(const std::string &file_name, GVC_t *gvc, Agraph_t
return
false
;
}
// TODO: refactor the read dot file
std
::
unique_ptr
<
ts_instance
>
file_manager
::
read_dot_file
(
const
std
::
string
&
file_name
)
{
// graphviz context
GVC_t
*
gvc
=
gvContext
();
Agraph_t
*
graph
;
std
::
unique_ptr
<
ts_instance
>
value1
;
if
(
load_graph
(
file_name
,
gvc
,
graph
,
value1
))
return
value1
;
// graph variables
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
node
>
>
nodesMap
;
std
::
vector
<
std
::
shared_ptr
<
node
>
>
nodes
;
std
::
vector
<
std
::
shared_ptr
<
edge
>
>
edges
;
void
file_manager
::
load_graph_into_program
(
Agraph_t
*
graph
,
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
node
>>&
nodesMap
,
std
::
vector
<
std
::
shared_ptr
<
edge
>>&
edges
)
{
// Iterate over the nodes
for
(
Agnode_t
*
n
=
agfstnode
(
graph
);
n
;
n
=
agnxtnode
(
graph
,
n
))
{
std
::
string
nodeName
=
agnameof
(
n
);
nodesMap
.
insert
(
std
::
make_pair
(
nodeName
,
std
::
make_
unique
<
node
>
(
nodeName
)));
nodesMap
.
insert
(
std
::
make_pair
(
nodeName
,
std
::
make_
shared
<
node
>
(
nodeName
)));
}
// Iterate over the edges (directed)
...
...
@@ -84,6 +71,24 @@ std::unique_ptr<ts_instance> file_manager::read_dot_file(const std::string &file
edges
.
push_back
(
std
::
move
(
edgePtr
));
}
}
}
std
::
unique_ptr
<
ts_instance
>
file_manager
::
read_dot_file
(
const
std
::
string
&
file_name
)
{
// graphviz context
GVC_t
*
gvc
=
gvContext
();
// loading graph from a file
Agraph_t
*
graph
;
std
::
unique_ptr
<
ts_instance
>
value1
;
if
(
load_graph
(
file_name
,
gvc
,
graph
,
value1
))
return
value1
;
// graph variables
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
node
>
>
nodesMap
;
std
::
vector
<
std
::
shared_ptr
<
node
>
>
nodes
;
std
::
vector
<
std
::
shared_ptr
<
edge
>
>
edges
;
// converting graph into vectors of nodes and edges
load_graph_into_program
(
graph
,
nodesMap
,
edges
);
// Free the graph and close the context
agclose
(
graph
);
...
...
This diff is collapsed.
Click to expand it.
files/file_manager.hpp
+
4
−
0
View file @
48949765
...
...
@@ -3,6 +3,7 @@
#include
<cgraph.h>
#include
<gvcext.h>
#include
<map>
#include
<string>
#include
<__filesystem/directory_entry.h>
...
...
@@ -16,6 +17,9 @@ public:
static
bool
load_graph
(
const
std
::
string
&
file_name
,
GVC_t
*
gvc
,
Agraph_t
*&
graph
,
std
::
unique_ptr
<
ts_instance
>
&
value1
);
static
void
load_graph_into_program
(
Agraph_t
*
graph
,
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
node
>>&
nodesMap
,
std
::
vector
<
std
::
shared_ptr
<
edge
>>&
edges
);
static
std
::
unique_ptr
<
ts_instance
>
read_dot_file
(
const
std
::
string
&
file_name
);
static
std
::
vector
<
std
::
filesystem
::
directory_entry
>
get_dot_instances
(
const
std
::
string
&
directory_path
);
...
...
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