16
Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ttp://gsd.uwaterloo.ca http ://necsis.ca http ://clafer.org

Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Embed Size (px)

Citation preview

Page 1: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Directed Graph Reachability in the

Presence of VariabilityMichał Antkiewicz

Oct 26, 2015University of Waterloo

http://gsd.uwaterloo.ca http://necsis.cahttp://clafer.org

Page 2: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

We’d like to…1. Model directed graphs with variability2. Enforce or verify reachability

Hands on mini-tutorial:http://t3-necsis.cs.uwaterloo.ca:8091/graphReachability

Page 3: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Requirements

• Directed graph • or multi-graph

• Optional edges or multiple targets• Edges have weight• Optional nodes• Enforce or verify that in all possible graphs a given node is reachable

from another node

N1

N2

N3?

N4E4?(2)

E1?(1)

E2?(2)

E3?(5) E5?(1)

Page 4: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Modeling using Clafer

• Directed graph• Outgoing edges disappear with

the node

• Edges have weight

• Directed multi-graph

abstract Node * abstract Edge -> Node * weight -> integer [ this.dref > 0 ]

abstract Node * abstract Edge ->> Node *

Page 5: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Modeling a Concrete Graph with Variability

abstract Node * abstract Edge ->> Node * weight -> integer [ this > 0 ]

N1

N2

N3?

N4

E1?(1)

E3?(5)

E4?(2)

E5?(1)

E2?(2)

N1 : Node 1 E1 : Edge -> N2 ? [ weight = 1 ] E2 : Edge -> N2 ? [ weight = 2 ] E3 : Edge -> N3 ? [ weight = 5 ]N2 : Node E4 : Edge -> N3 ? [ weight = 2 ]N3 : Node ? E5 : Edge -> N4 ? [ weight = 1 ]N4 : Node

Reference refinement of: abstract Edge ->> Node *

Page 6: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

A Few Possible Graphs

N1

N2

N3

N4 N1

N2

N3

N4

E1(1)

E5(1)

… N1

N2

N3

N4

E1(1)

E3(5)

E4(2)

E5(1)

E2?(2)…

N1

N2

N4 N1

N2

N4

E1(1)

… N1

N2

N4

E1(1)

E2(2)…

Page 7: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Enforcing reachability of N4 from N1

• N4 is in the set of nodes reachable from N1• “N1.Edge”

• N2, N3

• “N1.Edge.Edge”• = “(N2, N3).Edge”• N3, N4

• “N1.^Edge”• Transitive closure (^) is

“N1.Edge ++ N1.Edge.Edge ++ …”

• Finally“[ N4 in N1.^Edge ]”

N1

N2

N3

N4

E1?(1)

E3?(5)

E4?(2)

E5?(1)

E2?(2)

Page 8: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Unfortunately, transitive closure is not yet*

implemented in ClaferWe must escape to Alloy to write that constraint

* It is at the top of the list….

Page 9: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Translation to Alloy

abstract Node * abstract Edge ->> Node * weight -> integer

abstract sig Node{ r_Edge : set Edge }

abstract sig Edge{ Edge_ref : one Node, r_weight : one weight }{ one @r_Edge.this }

sig weight{ weight_ref : one Int }{ one @r_weight.this }

[ N4 in N1.^Edge ]

[alloy|fact { N4 in N1.^(r_Edge.Edge_ref)}|]

Page 10: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

A Few Possible Graphs

N1

N2

N3

N4

E1?(1)

E4?(2)

E5?(1)

N1

N2

N3

N4

E3?(5) E5?(1)

N1

N2

N3

N4E4?(2)

E5?(1)

E2?(2)

N1

N2

N3

N4

E1?(1)

E3?(5)

E4?(2)

E5?(1)

E2?(2)N1

N2

N3

N4

E1?(1)

E3?(5) E5?(1)

E2?(2)N1

N2

N3

N4

E1?(1)

E4?(2)

E5?(1)

E2?(2)

Page 11: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Exercises

http://t3-necsis.cs.uwaterloo.ca:8091/graphReachability

Page 12: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Q1: Can you make N1 prohibited (that is give it cardinality 0) and get an instance? Why?

A: No. “N1.^Edge” will be an empty set because N1 is empty and N4 cannot be a subset of an empty set.

Page 13: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Q2: Make the edges E1 and E2 mutually exclusive.

Can they be put into a feature group as follows. Why?

A1: “[E1 xor E2]”. A2: No, edges must be nested directly under nodes.

N1

N2

N3

N4

E1?(1)

E2?(2)

E3?(5)

E4?(2)

E5?(1)

xor N1 : Node 1 xor group E1 : Edge -> N2 ? E2 : Edge -> N2 ?

Page 14: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Q3: Make the edge E2 point to either N2 or N3.

A: “E2 : Edge -> N2 ++ N3 ?”.

N1

N2

N3

N4

E1?(1)

E2?(2)

E3?(5)

E4?(2)

E5?(1)

xor

N1

N2

N3

N4

E1?(1)

E2?(2)

E3?(5)

E4?(2)

E5?(1)

N2++N3

E2->N3

E2->N2

Page 15: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Q4: Change the graph such that N4 is always reachable from N1 with minimal # of edges.

A: “N3 : Node E5 : Edge -> N4 [ lone (E1 ++ E2) ] [ E3 xor E4 ] [ E4 <=> E1 || E2 ]”

[alloy|assert N4isReachable { N4 in N1.^(r_Edge.Edge_ref)}check N4isReachable for 1 but 5 Edge, 4 Node, 5 weight|]

N1

N2

N3

N4

E1?(1)

E2?(2)

E3?(5)

E4?(2)

E5 (1)

mux

xor

Page 16: Directed Graph Reachability in the Presence of Variability Michał Antkiewicz Oct 26, 2015 University of Waterloo ://necsis.ca

Directed Graph Reachability in the

Presence of Variability

Thank You!

http://gsd.uwaterloo.ca http://necsis.cahttp://clafer.org