graph: replace the existing "alternating" interface

* spot/graph/graph.hh: Use the sign bit of destination state X to
designate a universal edge.  Store the destinations of such an edge in a
separate array, at index ~X.
* spot/graph/ngraph.hh, tests/core/graph.cc, tests/core/graph.test,
tests/core/ngraph.cc: Adjust test case to the new interface.
This commit is contained in:
Alexandre Duret-Lutz 2016-11-23 21:08:11 +01:00
parent dcd21aaabf
commit 4903f086e3
5 changed files with 188 additions and 67 deletions

View file

@ -1,6 +1,6 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014, 2015 Laboratoire de Recherche et Développement
// de l'Epita.
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
//
@ -225,30 +225,29 @@ f6()
f += t.first;
h += t.second;
}
return f == 3 && (h > 2.49 && h < 2.51);
return f == 3 && (h > 2.49 && h < 2.51) && !g.is_alternating();
}
static bool
f7()
{
spot::digraph<int, int, true> g(3);
spot::digraph<int, int> g(3);
auto s1 = g.new_state(2);
auto s2 = g.new_state(3);
auto s3 = g.new_state(4);
g.new_edge(s1, {s2, s3}, 1);
g.new_edge(s1, {s3}, 2);
g.new_edge(s2, {s3}, 3);
g.new_edge(s3, {s2}, 4);
g.new_univ_edge(s1, {s2, s3}, 1);
g.new_univ_edge(s1, {s3}, 2);
g.new_univ_edge(s2, {s3}, 3);
g.new_univ_edge(s3, {s2}, 4);
int f = 0;
for (auto& t: g.out(s1))
{
for (auto& tt: t.dst)
{
f += t.label * g.state_data(tt);
}
}
return f == 15;
for (unsigned tt: g.univ_dests(t))
f += t.label * g.state_data(tt);
g.dump_storage(std::cout);
return f == 15 && g.is_alternating();
}

View file

@ -1,7 +1,7 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
# Copyright (C) 2014, 2016 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
@ -71,6 +71,16 @@ digraph {
2 [label="4"]
2 -> 1 [label="4"]
}
t1: (s0, d0) t2
t2: (s0, s2) t0
t3: (s1, s2) t0
t4: (s2, s1) t0
s0: t1 t2
s1: t3 t3
s2: t4 t4
d0: #2
d1: s1
d2: s2
digraph {
0 [label="(2,4)"]
0 -> 1 [label="(1,3)"]
@ -84,4 +94,3 @@ digraph {
EOF
diff stdout expected

View file

@ -264,32 +264,30 @@ static bool f6()
f += t.first;
h += t.second;
}
return f == 3 && (h > 2.49 && h < 2.51);
return f == 3 && (h > 2.49 && h < 2.51) && !g.is_alternating();
}
static bool f7()
{
typedef spot::digraph<int, int, true> graph_t;
typedef spot::digraph<int, int> graph_t;
graph_t g(3);
spot::named_graph<graph_t, std::string> gg(g);
auto s1 = gg.new_state("s1", 2);
gg.new_state("s2", 3);
gg.new_state("s3", 4);
gg.new_edge("s1", {"s2", "s3"}, 1);
gg.new_edge("s1", {"s3"}, 2);
gg.new_edge("s2", {"s3"}, 3);
gg.new_edge("s3", {"s2"}, 4);
gg.new_univ_edge("s1", {"s2", "s3"}, 1);
// Standard edges can be used as well
gg.new_edge("s1", "s3", 2);
gg.new_univ_edge("s2", {"s3"}, 3);
gg.new_univ_edge("s3", {"s2"}, 4);
int f = 0;
for (auto& t: g.out(s1))
{
for (auto& tt: t.dst)
{
f += t.label * g.state_data(tt);
}
}
return f == 15;
for (unsigned tt: g.univ_dests(t.dst))
f += t.label * g.state_data(tt);
return f == 15 && g.is_alternating();
}