Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mining Frequent Subgraphs

Similar presentations


Presentation on theme: "Mining Frequent Subgraphs"— Presentation transcript:

1 Mining Frequent Subgraphs
COMP Seminar Spring 2011

2 Overview Introduction
Finding recurring subgraphs from graph databases. FSG gSpan FFSM 1L06 Left: social network right protein structure 9/18/2018

3 Labeled Graph We define a labeled graph G as a five element tuple G = {V, E, V, E, } where V is the set of vertices of G, E  V V is a set of undirected edges of G, V (E) are set of vertex (edge) labels,  is the labeling function: V  V and E  E that maps vertices and edges to their labels. p2 p5 a b d y x (P) p1 p3 p4 c a b y x (Q) q1 q3 q2 a b y (S) s1 s3 s2 9/18/2018

4 Frequent Subgraph Mining
Input: A set GD of labeled undirected graphs p2 p5 a b d y x (P) p1 p3 p4 c  = 2/3 a b y x (Q) q1 q3 q2 a b y (S) s1 s3 s2 Output: All frequent subgraphs (w. r. t. ) from GD. a b y x a b a b y x a b y x 9/18/2018

5 Finding Frequent Subgraphs
Given a graph database GD = {G0,G1,…,Gn}, find all subgraphs appearing in at least  graphs. Isomorphic subgraphs are considered the same subgraph. Apriori approaches Generation of subgraph candidates is complicated and expensive. Subgraph isomorphism is an NP-complete problem, so pruning is expensive.

6 Apriori-Based, Breadth-First Search
Methodology: breadth-search, joining two graphs AGM (Inokuchi, et al. PKDD’00) generates new graphs with one more node FSG (Kuramochi and Karypis ICDM’01) generates new graphs with one more edge 9/18/2018

7 FSG Algorithm K = 1 F1 = all frequent edges Repeat K = K + 1;
CK = join(FK-1) FK = frequent patterns in CK Until FK is empty 9/18/2018

8 Join: Key Operation Join(L) =  join(P, Q) for all P, Q  L
Join(P, Q) = {G | P, Q,  G, |G| = |P| + 1, |P| = |Q|} Two graphs P and Q are joinable if the join of the two graphs produces an non-empty set Theorem: two graphs P and Q are joinable if P ∩ Q is a graph with size |P| -1 or share a common “core” with size P-1 9/18/2018

9 Multiplicity of Candidates
Case 1: identical vertex labels e a b a b e a a + e e b b e a b a a 9/18/2018

10 Multiplicity of Candidates
Case 2: Core contains identical labels a c b + a b c a c b a c b Core: The (k-1) subgraph that is common between the joint graphs 9/18/2018

11 Multiplicity of Candidates
Case 3: Core multiplicity a b a b a b + a b a b 9/18/2018

12 PATH Apriori-based approach Building blocks: edge-disjoint path
Identify all frequent paths Construct frequent graphs with 2 edge-disjoint paths Construct graphs with k+1 edge-disjoint paths from graphs with k edge-disjoint paths Repeat A graph with 3 edge-disjoint paths 9/18/2018

13 PATH Algorithm K = 1 F1 = all frequent paths Repeat K = K + 1;
CK = join(FK-1) FK = frequent patterns in CK Until FK is empty 9/18/2018

14 Challenges Graph isomorphism Subgraph isomorphism
Two graphs may have the same topology though their layouts are different Subgraph isomorphism How to compute the support value of a pattern 9/18/2018

15 Graph Isomorphism A graph is isomorphic if it is topologically equivalent to another graph 9/18/2018

16 Why Redundant Candidates?
All the algorithms may propose the same candidate several times. We need to keep track of the identical candidates to Avoid redundancy in results Avoid redundant search 9/18/2018

17 gSpan DFS without candidate generation DFS Representation
Relabels graph representation to support DFS. Discovers all frequent subgraphs without candidate generation or pruning. DFS Representation Map each graph to a DFS code (sequence). Lexicographically order the codes. Construct a search tree based on the lexicographic order.

18 Depth-First Search Tree
Three depth-first search trees of figure a. vi is the visitation order. Dotted lines are visits back to a visited node. Rightmost path is the path from v0->vN. (a) (b) (c) (d)

19 DFS Codes (start_index, end_index, start_label, edge_label, end_label)
Given ei = (i1,j1), e2 = (i2,j2): e1 < e2 if: i1 = i2 && j1 < j2 i1 < j1 && j1 = i2 code(G,T) = edge sequence of ei < ei+1 (a) (b) edge (b) (c) (d) (0,1,X,a,Y) (0,1,Y,a,X) (0,1,X,a,X) 1 (1,2,Y,b,X) (1,2,X,a,X) (1,2,X,a,Y) 2 (2,0,X,a,X) (2,0,X,b,Y) (2,0,Y,b,X) 3 (2,3,X,c,Z) (2,3,Y,b,Z) 4 (3,1,Z,b,Y) (3,0,Z,b,Y) (3,0,Z,c,X) 5 (1,4,Y,d,Z) (0,4,Y,d,Z) (2,4,Y,d,Z) (start_index, end_index, start_label, edge_label, end_label) e1 < e2 if start at same node and e1 ends at an earlier visited node. e1 < e2 if e1 starts at an earlier node than e2 ends at, and e1 ends at the node e2 starts at. G = graph. T = DFS tree of G. (c) (d)

20 DFS Lexicographic Order
∂ = code(G∂,T∂) = (a0,a1,…,am) ß = code(Gß,Tß) = (b0,b1,…,bn) ∂ ≤ ß iff (1) or (2): (1) (2) Minimum DFS code The minimum DFS code min(G), in DFS lexicographic order, is the canonical label of graph G. Graphs A and B are isomorphic if min(A) = min(B). 1. A prefix sequence of ∂ and ß is equal, and at <e bt. 2. ß is longer than ∂, but their common prefix elements are equal.

21 DFS Codes: Parents and Children
If ∂ = (a0,a1,…,am) and ß = (a0,a1,…,am,b): ß is the child of ∂. ∂ is the parent of ß. A valid DFS code requires that b grows from a vertex on the rightmost path. Rightmost path is the path from v0->vN in the DFS.

22 DFS Code Trees Organize DFS code nodes as parent-child.
Pre-order traversal follows DFS lexicographic order. If s and s’ are the same graph with different DFS codes, s’ is not the minimum and can be pruned.

23 gSpan D is the set of all graphs. S is the result set.
Algorithm 1: GraphSet_Projection(D,S) 1: sort labels in D by frequency 2: remove infrequent vertices and edges 3: relabel remaining vertices and edges 4: S’ = all frequent 1-edge graphs in D 5: sort S’ in DFS lexicographic order 6: S = S’ 7: foreach edge e in S’ do 8: s = graph defined by e 9: s.D = subgraphs in D containing e 10: Subgraph_Mining(D,S,s) 11: D = D - e 12: if |D| < minSup 13: break Subprocedure 1: Subgraph_Mining(D,S,s) 1: if s != min(s) 2: return 3: S = S U {s} 4: s’ = +1-edge children of s in s.D 5: foreach child c of s’ do 6: if support(c) ≥ minSup 7: Subgraph_Mining(Ds,S,c) Vertices = {A,B,C,…}. Edges = {a,b,c,…}. Subgraph_Mining grows all nodes in the subtree rooted at s. Each foreach iteration finds all frequent subgraphs (A,a,A), then (B,b,C) without (A,a,A).

24 Runtime: Synthetic Runtime (sec)

25 Runtime: Chemical Apriori (FSG) gSpan
Runtime (sec) Support Threshold (%) 1000 100 10 1 340 chemical compounds, 24 different atoms, 66 atom types, 4 bond types. Sparse: average 27 vertices, 28 edges per graph. Largest 214 vertices, 214 edges.

26 gSpan Advantages Lower memory requirements.
Faster than naïve FSG by an order of magnitude. No candidate generation. Lexicographic ordering minimizes search tree. False positives pruning. Any disadvantage? <100MB for chemical; FSG ran out of memory for support < 5%. Faster: synthetic 6-30 times; chemical times. FSM (Apriori) takes 10 minutes to process a dataset with 6.5% minimum support. gSpan completes in 10 seconds.


Download ppt "Mining Frequent Subgraphs"

Similar presentations


Ads by Google