Try to not draw duplicate arrows.
This cleans up some graphs rather nicely. There is only one potential drawback (not observed in practive): If two bindings have the same from/to, but different interpretations, we might lose information. In particular the 'select' intermediate nodes might pose a problem and we would be better off by not having any interpretation on what is selected.
This commit is contained in:
parent
8fe754f4ec
commit
03522b7108
@ -415,7 +415,30 @@ iterate_bindings (int (*func) (Binding b))
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Determine whether two bindings have the same source and destination
|
||||||
|
int
|
||||||
|
same_binding (const Binding b1, const Binding b2)
|
||||||
|
{
|
||||||
|
if (b1 == b2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ((b1 != NULL) && (b2 != NULL))
|
||||||
|
{
|
||||||
|
if ((b1->done) && (b2->done))
|
||||||
|
{
|
||||||
|
if ((b1->run_to == b2->run_to) && (b1->ev_to == b2->ev_to))
|
||||||
|
{
|
||||||
|
if ((b1->run_from == b2->run_from)
|
||||||
|
&& (b1->ev_from == b2->ev_from))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//! Iterate over preceding bindings (this does not include stuff bound to the same destination)
|
//! Iterate over preceding bindings (this does not include stuff bound to the same destination)
|
||||||
/**
|
/**
|
||||||
|
@ -51,6 +51,7 @@ void bindingDone ();
|
|||||||
|
|
||||||
int binding_print (Binding b);
|
int binding_print (Binding b);
|
||||||
int valid_binding (Binding b);
|
int valid_binding (Binding b);
|
||||||
|
int same_binding (const Binding b1, const Binding b2);
|
||||||
|
|
||||||
int goal_add (Term term, const int run, const int ev, const int level);
|
int goal_add (Term term, const int run, const int ev, const int level);
|
||||||
int goal_add_fixed (Term term, const int run, const int ev, const int fromrun,
|
int goal_add_fixed (Term term, const int run, const int ev, const int fromrun,
|
||||||
|
37
src/dotout.c
37
src/dotout.c
@ -996,8 +996,6 @@ regularModifiedLabel (Binding b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//!
|
|
||||||
|
|
||||||
//! Draw a single binding
|
//! Draw a single binding
|
||||||
void
|
void
|
||||||
drawBinding (const System sys, Binding b)
|
drawBinding (const System sys, Binding b)
|
||||||
@ -1143,8 +1141,10 @@ int
|
|||||||
drawAllBindings (const System sys)
|
drawAllBindings (const System sys)
|
||||||
{
|
{
|
||||||
List bl;
|
List bl;
|
||||||
|
List bldone;
|
||||||
int fromintr;
|
int fromintr;
|
||||||
|
|
||||||
|
bldone = NULL;
|
||||||
fromintr = 0;
|
fromintr = 0;
|
||||||
for (bl = sys->bindings; bl != NULL; bl = bl->next)
|
for (bl = sys->bindings; bl != NULL; bl = bl->next)
|
||||||
{
|
{
|
||||||
@ -1157,16 +1157,36 @@ drawAllBindings (const System sys)
|
|||||||
// still show it somewhere.
|
// still show it somewhere.
|
||||||
if (b->done)
|
if (b->done)
|
||||||
{
|
{
|
||||||
// done, draw
|
// Check whether we already drew it
|
||||||
drawBinding (sys, b);
|
List bl2;
|
||||||
// from intruder?
|
int drawn;
|
||||||
if (sys->runs[b->run_from].protocol == INTRUDER)
|
|
||||||
|
drawn = false;
|
||||||
|
for (bl2 = bldone; bl2 != NULL; bl2 = bl2->next)
|
||||||
{
|
{
|
||||||
if (sys->runs[b->run_from].role == I_M)
|
if (same_binding (b, (Binding) bl2->data))
|
||||||
{
|
{
|
||||||
fromintr++;
|
drawn = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!drawn)
|
||||||
|
{
|
||||||
|
// done, draw
|
||||||
|
drawBinding (sys, b);
|
||||||
|
|
||||||
|
// from intruder?
|
||||||
|
if (sys->runs[b->run_from].protocol == INTRUDER)
|
||||||
|
{
|
||||||
|
if (sys->runs[b->run_from].role == I_M)
|
||||||
|
{
|
||||||
|
fromintr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add to drawn list
|
||||||
|
bldone = list_add (bldone, b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1174,6 +1194,7 @@ drawAllBindings (const System sys)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
list_destroy (bldone); // bindings list
|
||||||
return fromintr;
|
return fromintr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user