Subgraph Isomorphism Problem Simple algorithms. Given two graphs G = (V,E) and H = (W,F) is there a subgraph of H that is isomorphic to G?

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Fc. Consider the following problem (csp5) variables V[1] to V[10] uniform domains D[1] to D[10] = {1,2,3} constraints V[1] = V[4] V[4] > V[7] V[7] = V[10]
Backward Checking Search BT, BM, BJ, CBJ. An example problem Colour each of the 5 nodes, such that if they are adjacent, they take different colours.
DS.GR.14 Graph Matching Input: 2 digraphs G1 = (V1,E1), G2 = (V2,E2) Questions to ask: 1.Are G1 and G2 isomorphic? 2.Is G1 isomorphic to a subgraph of.
Constraint Based Reasoning over Mutex Relations in Graphplan Algorithm Pavel Surynek Charles University, Prague Czech Republic.
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 Constraint Satisfaction Problems. 2 Intro Example: 8-Queens Generate-and-test: 8 8 combinations.
CSE 390B: Graph Algorithms Based on CSE 373 slides by Jessica Miller, Ruth Anderson 1.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Constraint Satisfaction problems (CSP)
Graph Isomorphism Algorithms and networks. Graph Isomorphism 2 Today Graph isomorphism: definition Complexity: isomorphism completeness The refinement.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Review: Constraint Satisfaction Problems How is a CSP defined? How do we solve CSPs?
9.3: Representing Graphs and Graph Isomorphism. Graphs, Edge tables, and adjacency matrices a bababab cdcdcdc edge lists Vertex adjacency vertexinitial.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 excerpts Graphs (breadth-first-search)
Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
Applied Discrete Mathematics Week 12: Trees
CS 410 Applied Algorithms Applied Algorithms Lecture #3 Data Structures.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lectures 3 Tuesday, 9/25/01 Graph Algorithms: Part 1 Shortest.
Graph Algorithms: Part 1
Jean-Charles REGIN Michel RUEHER ILOG Sophia Antipolis Université de Nice – Sophia Antipolis A global constraint combining.
Constraint Propagation (Where a better exploitation of the constraints further reduces the need to make decisions) R&N: Chap. 5 + Chap. 24, p
CS 206 Introduction to Computer Science II 11 / 05 / 2008 Instructor: Michael Eckmann.
SubSea: An Efficient Heuristic Algorithm for Subgraph Isomorphism Vladimir Lipets Ben-Gurion University of the Negev Joint work with Prof. Ehud Gudes.
CS 206 Introduction to Computer Science II 03 / 25 / 2009 Instructor: Michael Eckmann.
Chapter 4 Graphs.
Register Allocation and Spilling via Graph Coloring G. J. Chaitin IBM Research, 1982.
Graphs - according to the mathematicians An undirected graph is 2-tuple: G=(V,E) a set of vertices a set of edges Vertices = {A, B, C, D, E} Edges = {
Computer Science 112 Fundamentals of Programming II Graph Algorithms.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 Graphs.
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
Representing and Using Graphs
Graph pattern matching Graph GGraph Qisomorphism f(a) = 1 f(b) = 6 f(c) = 8 f(d) = 3 f(g) = 5 f(h) = 2 f(i) = 4 f(j) = 7.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
ANALYSIS AND IMPLEMENTATION OF GRAPH COLORING ALGORITHMS FOR REGISTER ALLOCATION By, Sumeeth K. C Vasanth K.
Graphs. Made up of vertices and arcs Digraph (directed graph) –All arcs have arrows that give direction –You can only traverse the graph in the direction.
Problem Solving with Constraints Lookahead Schemas 1 Foundations of Constraint Processing CSCE496/896, Fall
Review Test1. Robotics & Future Technology Future of Intelligent Systems / Ray Kurzweil futurist Ray Kurzweil / A Long Bet A Long Bet / Robot Soccer.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
An Introduction to Artificial Intelligence Lecture 5: Constraint Satisfaction Problems Ramin Halavati In which we see how treating.
Arc consistency AC5, AC2001, MAC. AC5 A generic arc-consistency algorithm and its specializations AIJ 57 (2-3) October 1992 P. Van Hentenryck, Y. Deville,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Graph Connectivity This discussion concerns connected components of a graph. Previously, we discussed depth-first search (DFS) as a means of determining.
Chapter 05 Introduction to Graph And Search Algorithms.
Outline  Introduction  Subgraph Pattern Matching  Types of Subgraph Pattern Matching  Models of Computation  Distributed Algorithms  Performance.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
Constraint Propagation CS121 – Winter Constraint Propagation2 Constraint Propagation … … is the process of determining how the possible values of.
Cbj. What’s a csp? a set of variables each with a domain of values a collection of constraints (I’m going to assume binary for the present) assign each.
Algorithms and networks
Shortest Path Problems
Constraint Propagation
Algorithms and networks
Shortest Path Problems
Constraints and Search
Chapter 14 Graphs © 2006 Pearson Addison-Wesley. All rights reserved.
Graph Implementation.
Graphs G = (V, E) V are the vertices; E are the edges.
Graph Algorithms DS.GR.1 Chapter 9 Overview Representation
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Subgraph Isomorphism Problem Simple algorithms

Given two graphs G = (V,E) and H = (W,F) is there a subgraph of H that is isomorphic to G?

Given two graphs G = (V,E) and H = (W,F) is there a subgraph of H that is isomorphic to G? “Is there a copy of the pattern graph (G) in the target graph (H)”

Given two graphs G = (V,E) and H = (W,F) is there a subgraph of H that is isomorphic to G? “Is there a copy of the pattern graph (G) in the target graph (H)” NP-hard in general

a bc GH

a bc GH One of many mappings

a bc GH Note: varieties of interpretation (induced, non-induced)

a bc GH Here: map a pattern vertex i (in G) to a target vertex v (in H) iff degree(i) ≤ degree(v) map pattern vertices i and j to target vertices v and w iff adjacent(G,i,j) → adjacent(H,v,w) mapping is injective

a bc GH map a pattern vertex i (in G) to a target vertex v (in H) iff degree(i) ≤ degree(v) map pattern vertices i and j to target vertices v and w iff adjacent(G,i,j) → adjacent(H,v,w) mapping is injective

a bc GH Model/Algorithm Create a set of variable v 1 to v n corresponding to pattern vertices (those in G) Each variable has as a domain the vertices in the target graph (H) Using a backtracking search, instantiate the variables respecting the constraints above map a pattern vertex i (in G) to a target vertex v (in H) iff degree(i) ≤ degree(v) map pattern vertices i and j to target vertices v and w iff adjacent(G,i,j) → adjacent(H,v,w) mapping is injective

a bc GH Model/Algorithm Create a set of variable v 1 to v n corresponding to pattern vertices (those in G) Each variable has as a domain the vertices in the target graph (H) Using a backtracking search, instantiate the variables respecting the constraints above Remove from domain of v i target vertices with insufficient degree map a pattern vertex i (in G) to a target vertex v (in H) iff degree(i) ≤ degree(v) map pattern vertices i and j to target vertices v and w iff adjacent(G,i,j) → adjacent(H,v,w) mapping is injective

a bc GH Model/Algorithm Create a set of variable v 1 to v n corresponding to pattern vertices (those in G) Each variable has as a domain the vertices in the target graph (H) Using a backtracking search, instantiate the variables respecting the constraints above Remove from domain of v i target vertices with insufficient degree Remove from domain of v i target vertices with insufficient neighbourhood degree sequence map a pattern vertex i (in G) to a target vertex v (in H) iff degree(i) ≤ degree(v) map pattern vertices i and j to target vertices v and w iff adjacent(G,i,j) → adjacent(H,v,w) mapping is injective

a bc GH Model/Algorithm Create a set of variable v 1 to v n corresponding to pattern vertices (those in G) Each variable has as a domain the vertices in the target graph (H) Using a backtracking search, instantiate the variables respecting the constraints above Remove from domain of v i target vertices with insufficient degree Remove from domain of v i target vertices with insufficient neighbourhood degree sequence Label vertices with some invariant, and filter map a pattern vertex i (in G) to a target vertex v (in H) iff degree(i) ≤ degree(v) map pattern vertices i and j to target vertices v and w iff adjacent(G,i,j) → adjacent(H,v,w) mapping is injective

Neighbourhood degree sequence

Domains of variables

NOTE: vertex G can be removed and labels updated …

In CP-speak, this is 1-consistency

Simple algorithm (0)

Simple algorithm (SIP0) At top of search, filter domains wrt vertex labels In a backtracking search Select a variable v i Assign v i a value x from its domain For all uninstantiated variables Remove x from domain of v j If adjacent(G,i,j) Then remove from domain of v j all values y where ¬adjacent(H,x,y) If domain wipeout Then try next value in domain of v i and if no more values, backtrack

Simple algorithm: implementation Adjacency matrices are arrays of bitsets adj[A] is adj(F) is Variable domains are bitsets dom(1) is dom(4) is If adjacent(G,i,j) and v i ← x Then dom(j) ← dom(j) ˄ adj(x) Else dom(j).unset(x)

Simple algorithm: implementation Exploit parallelism in the hardware Adjacency matrices are arrays of bitsets adj[A] is adj(F) is Variable domains are bitsets dom(1) is dom(4) is If adjacent(G,i,j) and v i ← x Then dom(j) ← dom(j) ˄ adj(x) Else dom(j).unset(x)

In CP-speak, this is forward checking (fc)

Simple algorithm (SIPcbj) Jump!

Associate with each variable a conflict set confSet i If the instantiation of v i with value x removes values from the domain of v j Then confSet j.set(i,true) If domain wipeout on v j Then confSet i ← confSet i ˅ confSet j dom(i).unset(x) Simple algorithm (SIPcbj)

Associate with each variable a conflict set confSet i If the instantiation of v i with value x removes values from the domain of v j Then confSet j.set(i,true) If domain wipeout on v j Then confSet i ← confSet i ˅ confSet j dom(i).unset(x) If domain wipeout on v i Then return confSet i Else new confSet ← expand({v i+1 … v n }) Simple algorithm (SIPcbj)

Associate with each variable a conflict set confSet i If the instantiation of v i with value x removes values from the domain of v j Then confSet j.set(i,true) If domain wipeout on v j Then confSet i ← confSet i ˅ confSet j dom(i).unset(x) If domain wipeout on v i Then return confSet i Else new confSet ← expand({v i+1 … v n }) Simple algorithm (SIPcbj) If consistent and ¬confSet.get(i) Then return confSet

In CP-speak, this is forward checking with conflict directed backjumping (fc-cbj) Simple algorithm (SIPcbj)

Simple algorithm (SIP1) v i ← x Neighbourhood domain nebDom ← Ө Number of neighbours neb ← 0 For all uninstantiated variables j If adjacent(G,i,j) Then dom(j) ← dom(j) ˄ adj(x) nebDom ← nebDom ˅ dom(j) neb++ If |nebDom| < neb Then fail

Simple algorithm (SIP1) v i ← x Neighbourhood domain nebDom ← Ө Number of neighbours neb ← 0 For all uninstantiated variables j If adjacent(G,i,j) Then dom(j) ← dom(j) ˄ adj(x) nebDom ← nebDom ˅ dom(j) neb++ If |nebDom| < neb Then fail If there are insufficient target vertices in the domains of vertices adjacent to the current vertex … fail!

Simple algorithm (SIP1) v i ← x Neighbourhood domain nebDom ← Ө Number of neighbours neb ← 0 For all uninstantiated variables j If adjacent(G,i,j) Then dom(j) ← dom(j) ˄ adj(x) nebDom ← nebDom ˅ dom(j) neb++ If |nebDom| < neb Then fail LV2002 If there are insufficient target vertices in the domains of vertices adjacent to the current vertex … fail!

Simple algorithm (SIP2) Given variables v i and v j where adjacent(G,i,j) For x in dom(i) supported ← false For y in dom(j) while ¬supported supported ← adjacent(H,x,y) If ¬supported Then remove x from dom(i)

Simple algorithm (SIP2) Given variables v i and v j where adjacent(G,i,j) For x in dom(i) supported ← false For y in dom(j) while ¬supported supported ← adjacent(H,x,y) If ¬supported Then remove x from dom(i) This is revise

Simple algorithm (SIP2) Given variables v i and v j where adjacent(G,i,j) For x in dom(i) supported ← false For y in dom(j) while ¬supported supported ← adjacent(H,x,y) If ¬supported Then remove x from dom(i) This is revise Do this until we reach a fixed point (no removals) Do this at top of search

Simple algorithm (SIP2) Given variables v i and v j where adjacent(G,i,j) For x in dom(i) supported ← false For y in dom(j) while ¬supported supported ← adjacent(H,x,y) If ¬supported Then remove x from dom(i) This is revise Do this until we reach a fixed point (no removals) Do this at top of search This is edge arc-consistency

ac3 making better use of BitSet (algorithm SIP2b)

Simple algorithm (SIP3) Sort variables in non-decreasing order of domain size totalDomain ← Ө nbVars ← 0 for i in 1.. n totalDomain ← totalDomain ˅ dom(i) nbVars++ If |totalDomain| < nbVars Then return false If |totalDomain| = nbVars Then return true return true

Simple algorithm (SIP3) Sort variables in non-decreasing order of domain size totalDomain ← Ө nbVars ← 0 for i in 1.. n totalDomain ← totalDomain ˅ dom(i) nbVars++ If |totalDomain| < nbVars Then return false If |totalDomain| = nbVars Then return true return true Do this at top of search Do this inside search before a recursive call NOTE: sorted variables then exploited as a variable ordering heuristic

Simple algorithm (SIP4/5) Compute the shortest distance between all pairs of vertices in G Compute the shortest distance between all pairs of vertices in H For all pairs of vertices i and j in G For all pair of vertices x and y in H If minDistance(G,i,j) < minDistance(H,x,y) Then disallow pair of assignments v i ← x and v j ← y

Simple algorithm (SIP4/5) Compute the shortest distance between all pairs of vertices in G Compute the shortest distance between all pairs of vertices in H For all pairs of vertices i and j in G For all pair of vertices x and y in H If minDistance(G,i,j) < minDistance(H,x,y) Then disallow pair of assignments v i ← x and v j ← y Replace ac(edge) with ac(minDistance)

Simple algorithm (SIP4/5) Compute the shortest distance between all pairs of vertices in G Compute the shortest distance between all pairs of vertices in H For all pairs of vertices i and j in G For all pair of vertices x and y in H If minDistance(G,i,j) < minDistance(H,x,y) Then disallow pair of assignments v i ← x and v j ← y Replace ac(edge) with ac(minDistance) Identify “Hall sets” in lvTest

There is a long history of algorithms for SIP, dating from Ullmann (1972), J.J. McGregor (1979), Jean-Charles Regin, up to state of the art by Larrosa & Valiente, Solnon et al and most recently Christophe Lecoutre et al (CP2014) Conclusions

So far I have about 9 variations on the basic algorithm with the bitset encoding. I need to identify just how many variations there might be and perform a full set of experiments on the benchmarks Conclusions

So far I have about 9 variations on the basic algorithm with the bitset encoding. I need to identify just how many variations there might be and perform a full set of experiments on the benchmarks Conclusions We have variants for induced SIP and directed graphs with weighted edges

That’s all … thanks.