Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libcaml-grew
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
grew
libcaml-grew
Commits
b2a8c8b8
Commit
b2a8c8b8
authored
Jan 25, 2018
by
Bruno Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change to_dot function in Graph to support highlighted nodes
parent
d7b18b9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
+49
-2
src/grew_graph.ml
src/grew_graph.ml
+49
-2
No files found.
src/grew_graph.ml
View file @
b2a8c8b8
...
...
@@ -928,9 +928,56 @@ module G_graph = struct
let
conll
=
to_conll
?
domain
graph
in
Conll
.
to_string
(
Conll
.
normalize_multiwords
conll
)
(* -------------------------------------------------------------------------------- *)
let
to_dot
?
domain
?
main_feat
?
(
deco
=
G_deco
.
empty
)
graph
=
let
conll
=
to_conll
?
domain
graph
in
Conll
.
to_dot
conll
let
buff
=
Buffer
.
create
32
in
bprintf
buff
"digraph G {
\n
"
;
bprintf
buff
" node [shape=Mrecord];
\n
"
;
(* bprintf buff " rankdir=LR;\n"; *)
(* bprintf buff " node [shape=none];\n"; *)
(* nodes *)
Gid_map
.
iter
(
fun
id
node
->
let
decorated_feat
=
try
List
.
assoc
id
deco
.
G_deco
.
nodes
with
Not_found
->
(
""
,
[]
)
in
bprintf
buff
" N_%s [label=<%s>, color=%s]
\n
"
(
Gid
.
to_string
id
)
(
G_fs
.
to_dot
~
decorated_feat
?
main_feat
(
G_node
.
get_fs
node
))
(* TODO: add bgcolor in dot output *)
(
if
List
.
mem_assoc
id
deco
.
G_deco
.
nodes
then
"red"
else
"black"
)
)
graph
.
map
;
(* edges *)
Gid_map
.
iter
(
fun
id
node
->
Massoc_gid
.
iter
(
fun
tar
g_edge
->
let
deco
=
List
.
mem
(
id
,
g_edge
,
tar
)
deco
.
G_deco
.
edges
in
if
g_edge
=
G_edge
.
sub
then
bprintf
buff
" N_%s -> N_%s [dir=none];
\n
"
(
Gid
.
to_string
id
)
(
Gid
.
to_string
tar
)
else
bprintf
buff
" N_%s -> N_%s%s;
\n
"
(
Gid
.
to_string
id
)
(
Gid
.
to_string
tar
)
(
G_edge
.
to_dot
?
domain
~
deco
g_edge
)
)
(
G_node
.
get_next
node
)
)
graph
.
map
;
(* Set "rank=same" and more edge in debug modes *)
Gid_map
.
iter
(
fun
id
node
->
begin
match
G_node
.
get_succ
node
with
|
Some
s
when
!
Global
.
debug
->
bprintf
buff
" N_%s -> N_%s [label=
\"
SUCC
\"
, style=dotted, fontcolor=lightblue, color=lightblue]; {rank=same; N_%s; N_%s };
\n
"
(
Gid
.
to_string
id
)
(
Gid
.
to_string
s
)
(
Gid
.
to_string
id
)
(
Gid
.
to_string
s
)
|
Some
s
->
bprintf
buff
" {rank=same; N_%s; N_%s };
\n
"
(
Gid
.
to_string
id
)
(
Gid
.
to_string
s
)
|
_
->
()
end
)
graph
.
map
;
bprintf
buff
"}
\n
"
;
Buffer
.
contents
buff
end
(* module G_graph *)
...
...
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