Commit 60cc98e1 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain

Fixes #4

remove edge names, then cgraph uses internal ids and allows double edges
parent 8fbb3231
......@@ -67,7 +67,7 @@ set_draw_graph_driver(Driver) :-
export_graph('', Id, OutputFile) :-
!,
atom_concat(OutputFile, '.dot', FilenameDot),
export_graph('.dot', Id, FilenameDot).
export_graph('dot', Id, FilenameDot).
export_graph('dot', Id, OutputFile) :-
!,
......@@ -135,11 +135,10 @@ create_cgraph(Id, Graph) :-
\+ (
item([parent: Id, kind: edge, item: Edge, id: EdgeId]),
\+ (
format(atom(EdgeName), '~w', [Edge]),
Edge = (VertexA -> VertexB),
agnode(Graph, VertexA, false, NodeA),
agnode(Graph, VertexB, false, NodeB),
agedge(Graph, NodeA, NodeB, EdgeName, true, GraphvizEdge),
agedge(Graph, NodeA, NodeB, true, GraphvizEdge),
(
get_attribute(EdgeId, sign='-')
->
......@@ -153,8 +152,7 @@ create_cgraph(Id, Graph) :-
get_attribute(EdgeId, sign='±')
->
agset(GraphvizEdge, color, 'green4'),
format(atom(EdgeName2), '~w-<~w', [VertexA, VertexB]),
agedge(Graph, NodeA, NodeB, EdgeName2, true, GraphvizEdge2),
agedge(Graph, NodeA, NodeB, true, GraphvizEdge2),
agset(GraphvizEdge2, arrowhead, 'tee'),
agset(GraphvizEdge2, color, 'red')
;
......
......@@ -14,8 +14,8 @@ digraph(TargetFilename) :-
agnode(Graph, 'a', true, NodeA),
agnode(Graph, 'b', true, NodeB),
agnode(Graph, 'reaction_0', true, Reaction_0),
agedge(Graph, NodeA, Reaction_0, 'a -> reaction_0', true, _Edge0),
agedge(Graph, Reaction_0, NodeB, 'reaction_0 -> b', true, _Edge1),
agedge(Graph, NodeA, Reaction_0, true, _Edge0),
agedge(Graph, Reaction_0, NodeB, true, _Edge1),
agattr(Graph, node, shape, circle, _),
agset(Reaction_0, shape, box),
agwrite(Graph, TargetFilename),
......
......@@ -3,7 +3,7 @@
[
agattr/5,
agclose/1,
agedge/6,
agedge/5,
agget/3,
agnode/4,
agopen/3,
......
......@@ -106,21 +106,21 @@ pl_agclose(term_t graph_term) {
static foreign_t
pl_agedge(
term_t graph_term, term_t node0_term, term_t node1_term, term_t name_term,
term_t graph_term, term_t node0_term, term_t node1_term,
term_t create_flag_term, term_t edge_term
) {
Agraph_t *graph;
Agnode_t *node0;
Agnode_t *node1;
char *name;
int create_flag;
Agedge_t *edge;
PL_check(PL_get_graph(graph_term, &graph));
PL_check(PL_get_node(node0_term, &node0));
PL_check(PL_get_node(node1_term, &node1));
PL_check(PL_get_atom_chars(name_term, &name));
PL_check(PL_get_bool(create_flag_term, &create_flag));
PL_check(edge = agedge(graph, node0, node1, name, create_flag));
// Do not use a name, for some reason only internal IDs ensure double
// arrows
PL_check(edge = agedge(graph, node0, node1, NULL, create_flag));
PL_check(PL_unify_pointer(edge_term, edge));
PL_succeed;
......@@ -273,7 +273,7 @@ pl_gvRenderFilename(
PL_extension graphviz_predicates[] = {
{ "agattr", 5, (pl_function_t) pl_agattr, 0 },
{ "agclose", 1, (pl_function_t) pl_agclose, 0 },
{ "agedge", 6, (pl_function_t) pl_agedge, 0 },
{ "agedge", 5, (pl_function_t) pl_agedge, 0 },
{ "agget", 3, (pl_function_t) pl_agget, 0 },
{ "agnode", 4, (pl_function_t) pl_agnode, 0 },
{ "agsubg", 4, (pl_function_t) pl_agsubg, 0 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment