0% found this document useful (0 votes)
10 views19 pages

Presentation Graphs Homomorphism

Uploaded by

Jagoda Bobińska
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views19 pages

Presentation Graphs Homomorphism

Uploaded by

Jagoda Bobińska
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Graph pattern-matching

Jagoda Bobińska, Pasquale Gravante


Subgraph isomorphism

Pattern Target
Subgraph isomorphism

Pattern Target
Subgraph homomorphism

Pattern Target
Subgraph homomorphism

Pattern Target
Subgraph homomorphism - formal approach
B a b c d e
ɸTɸ ⊆ I
a 0 1 0 0 1 a
I ⊆ ɸɸT
b 1 0 1 0 0
e b B ⊆ ɸ Bʼ ɸT
c 0 1 0 1 0

d 0 0 1 0 1 ɸ x y z

e 1 0 0 0 1 d c a 0 1 0

Bʼ x y z b 1 0 0
x
x 0 1 1 c 0 0 1

y 1 0 1 d 0 1 0

z 1 1 1 y z e 0 0 1
Problems and solutions (?)
Subgraph isomorphism - NP complete

● pattern-matching for restricted classes of graphs (f. ex. trees)


● heuristics
● string pattern matching generalized to graph grammars

● equivalent pattern on smaller subgraphs


Theorem
Pattern-matching from a non-connected pattern to a target is equivalent to
pattern-matching from every connected component of the pattern to connected
components of the target.

Pattern Target
Lemma
Pattern-matching from a non-connected pattern to a target is equivalent to
pattern-matching from every connected component of the pattern to the whole target.

Pattern Target
GRAPH PATTERN MATCHING ALGORITHM
Basic search algorithm
Graphs:
𝐺 = (𝑉,𝐵): Pattern graph
𝐺′ = (𝑉′,𝐵′): Target graph
∣∣𝑉 = 𝑛 (number of nodes in the pattern graph)
∣ ∣
𝑉′ = 𝑚 (number of nodes in the target graph)
Graph Homomorphism:
Defined by a boolean 𝑛×𝑚 matrix Φ
Each row of Φ has exactly one true
Columns may have more than one true
Tree Representation:
Depth: 𝑛 (number of nodes in the pattern graph)
Branches: 𝑚 (number of possible mappings per node)
Example: For 𝑛=2, 𝑚=3, the tree depth is 2 and each node has 3 children
GRAPH PATTERN MATCHING ALGORITHM
Basic search algorithm
1. Starting with an 𝑛×𝑚 matrix whose elements are all true (one), the algorithm returns
the first leaf of the tree (in a depth-first search) that satisfies the conditions for graph
homomorfism, if any.

2. A test function implements the conditions for graph homomorphism.

3. The search for a homomorphism can also


be performed by using a previously found one
as the start matrix, and going either to the
next leaf of the tree that satisfies the
conditions to be a homomorphism, or the null
matrix if no further ones are found.
GRAPH PATTERN MATCHING ALGORITHM
Pruning the search tree

Idea:
We want to prune earlier branches of the tree that cannot lead to valid solutions, to
improve the efficiency of finding graph homomorphisms.

Branch Pruning:
Violation Detection: Branches are pruned immediately upon detecting that a
mapping violates the conditions necessary for a graph homomorphism.
Matrix Rearrangement: By rearranging the initial matrix, the algorithm can prune
branches earlier, reducing unnecessary computations.
Initial False Entries: Setting certain entries to false from the start helps in
preventing the exploration of mappings that will not lead to valid homomorphisms.
GRAPH PATTERN MATCHING ALGORITHM
Pruning the search tree
Improved Algorithm:
When mapping nodes, the adjacency relationships are preserved. This means that if
one node is adjacent to another in the pattern graph, their images in the target
graph must also be adjacent. This involves continuous checks to ensure valid
mappings respecting these adjacency conditions.

Key Functions:
mapable: Iterates through potential mappings of
node i in P to nodes in T, starting from node j, and
uses the “ismapable” function to check their validity.
ismapable: Checks if the mapped nodes maintain the adjacency relationships required
by the graph homomorphism definition.
GRAPH PATTERN MATCHING ALGORITHM
Improved search algorithm
Idea:
The algorithm breaks down the complex task of finding a pattern within a larger
graph into smaller, more manageable subproblems.
This method aims to reduce the complexity of finding graph homomorphisms
between the pattern and target graphs.
This is done by using the the connected components of the pattern graph.

Connected components:
A subset of nodes such that
there is a path between any two
nodes in this subset, and no
node in the subset is connected
to any node outside it.
GRAPH PATTERN MATCHING ALGORITHM
Improved search algorithm: How it works
1. Decomposition by Connected Components:
The algorithm first analyzes the pattern graph to identify its connected components.
Instead of trying to match the entire pattern graph to the target graph in one go, it
focuses on matching these smaller subgraphs (connected components) one at a time.
2. Step-by-Step Matching:
For each connected component, the algorithm searches for a corresponding match in
the target graph. This process is repeated for all connected components.
3. Incremental Composition:
Once matches for all connected components are found, these individual matches are
combined to form a complete mapping from the pattern graph to the target graph.
If any component fails to find a match, the algorithm concludes that the pattern graph
cannot be matched to the target graph in the required way.
EXPERIMENTAL RESULTS
Experimental Setup:
Matching experiments were conducted on random pattern graphs of order n,
random target graphs of order m (with 𝑛 ≤ 𝑚) and edge probability of 0.25.
The algorithm tested both basic search (search column) and improved search
with pruning (prune column).

Leaves Visited:
As the graph order increases, the number
of leaves visited increases significantly,
especially for the basic search.
The prune method consistently visits
fewer leaves compared to the basic
search method.
Number of leaves visited while searching for a homomorphism
EXPERIMENTAL RESULTS
Finding Homomorphism:
Time in seconds to find one homomorphism using different methods:
Basic search
Improved search with pruning
Decomposed search (decompose column)

Decomposed search shows


significant time savings when
compared to other methods,
especially as the order of the
graphs increases.

Number of leaves visited while searching for a homomorphism


CONCLUSIONS
Key Takeaways:

Decomposition Efficiency: The algorithm improves efficiency by decomposing the


pattern graph into connected components, significantly reducing the search space.

Enhanced Performance: Experimental results show better performance for very


dense graphs, with substantial reductions in the number of searches needed.

Specialization for Isomorphisms: The algorithm can also be specialized to find


isomorphic images (meaning there is a one-to-one correspondence between their
nodes), however this has to be done by decomposing the target graph instead of the
pattern graph.
THANK YOU FOR THE ATTENTION!

You might also like