pcg2012 presentation

18
Fast Exact Graph Matching Using Adjacency Matrices Marlon Etheredge Amsterdam University of Applied Sciences [email protected] May 29, 2012

Upload: marlon-etheredge

Post on 18-Jul-2015

161 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Pcg2012 presentation

Fast Exact Graph Matching Using AdjacencyMatrices

Marlon Etheredge

Amsterdam University of Applied Sciences

[email protected]

May 29, 2012

Page 2: Pcg2012 presentation

About Me

I Marlon EtheredgeI Student

I Amsterdam University of Applied SciencesI Specialization in Game Technology

I Senior Software EngineerI Realvine BV The NetherlandsI Freelance

I Owner Game StudioI MangoDown!I Catch-22, Winner Global Game Jam 2012 The Netherlands

Page 3: Pcg2012 presentation

About This Research

I DroidRacersI Pre-graduation projectI Strong focus on Procedurally Generated Content

I Builds on work by Joris DormansI Used a ’naıve’ algorithm for graph isomorphism in a projectI Tried to find a more convenient way to solve this problem

Page 4: Pcg2012 presentation

DroidRacersI Infinite Racing GameI Played on public screenI Controllable by Android Devices

I Scan the QRCode in the game screen to become a participantin the game

I Constantly changing game state and skill set of playersI Players can join or leave an active gameI The game should be altered according to these changes

I ProceduralContent

I Race tracksI Power upsI GoalsI Etc.

Page 5: Pcg2012 presentation

The Problem: Genetic vs Graph Based Procedural Content

I Requirement of realtime alternation of structures within thegame

I Evolutionary algorithms require an arbitrary number ofgenerations

I Undesired with the quick and direct way of transformations wedemand

I Graph Based Procedural Content offers us fast and directmodification of structures within the game

I Practically any structure within the game may be representedby a graph

I Allows for the modifications of a lot of structures within thegame

Page 6: Pcg2012 presentation

The Problem: Graph Isomorphism

I Graph Based Procedural Content requires fast realtime GraphTransformation

I Fast realtime algorithm for solving the Graph Isomorphismproblem

I Existing well-known algorithms including:I VF2

Mainly focuses on large graphsI Ullmann

Too slow for usage in our projectI R. Heckel

Exponential processing time

I Need for a fast algorithm still offering full flexibility

Page 7: Pcg2012 presentation

The Problem: Example

I A game of any kind might encapsulate the abstract structureas presented in the figure below

I A node within this graph might be any entity within the game,a connection defines a connection between the two entities

I We might want to replace the highlighted structure in thefigure with another structure to adjust our game according toa particular case

The subset matched in the graph

Subset in graph

A1

B2

B5

D3 D4

E7

C6

A9

B8A10

Page 8: Pcg2012 presentation

Naıve Search Operation

I Describing subgraph A by:

I An as a set of nodes existing in A

I Aout as a set of outgoing edges

I Ain as a set of incoming edges

I Aout ⊆ An, Ain ⊆ An

I Describing target graph G by:

I Gout as a set of outgoing edges

I Gin as a set of incoming edges

I Gout ⊆ Gn, Gin ⊆ Gn

I A search operation would recursively search every node inGout for a node in Aout, which would cause exponentialprocessing time as well as undesired levels of recursion

Page 9: Pcg2012 presentation

Our Algorithm: Adjacency Matrices

I Uses adjacency matricesI Adjacency matrix generation by trivial function

I For every connection in set set in a two dimensional by indexof first node and index of second node, a one

I Matrices should store connection count for rows and columns,convenient to store this at the end of the row or column

Pattern

C1

E2

B3

A4A5B6

C1 E2 B3 A4 A5 B6 l

C1 0 0 0 0 0 0 0E2 1 0 1 0 0 0 2B3 0 0 0 0 0 0 0A4 0 1 0 0 0 0 1A5 0 0 0 1 0 0 1B6 0 0 0 0 1 0 1l 1 1 1 1 1 0 0

Page 10: Pcg2012 presentation

Our Algorithm: Patterns

I Map containing a key and one or more value entriesI Key described the node type that requires the entries in the

values of the mapI Basically a representation of a row, using a node types as

storage type and node type that required connections as keyvalue

I Patterns are constructed from the subset graph adjacencymatrix

I Used to scan the adjacency matrix of the target graph, to testif edges exist for a specific node

I Set of patterns condenses more narrow when more matchesare found

Pattern

C1

E2

B3

A4A5B6

E{C ,B}B{A}A{A}A{E}

Page 11: Pcg2012 presentation

Our Algorithm: Explained

I Convert both the target graph as the subset graph intoadjacency matrices

I Extract patterns from the subset graph adjacency matrix

I Sort the set of patterns according to the number ofrequirements in the pattern

I Recursively search trough the node set of the target graph,adding all accepted requirements as matches

I In case we have found all requirements for the current pattern,mark the current node as an actual match and mark thecurrent pattern as used

I Recursively search through next patterns

Page 12: Pcg2012 presentation

Flexibility: Complex Search CasesI More complex search cases

I Example, in this graph the search operation should returnmultiple matches, both the upper set of nodes as the lower setof nodes

I Such a case is hard to successfully return in a traditionalsearch algorithm, since every connection that is entered needsto be stored and later searched again for the case of multipleequal branches

I Results in loss of performance on many equal branchesI Our algorithm handles such a case naturally, since both

branches are already pushed inside the list of matches that aresearched recursively

A5

A1

B2

B3

B4

A0 A0 A1

B2

B3

Page 13: Pcg2012 presentation

Flexibility: Advanced Node Types

I Along with solving more complex cases of graph matching, ouralgorithm allows for the matching of more complex node types

I For instanceI Wildcard: A node type that allows for any graph structure

positioned at the wildcard node in a subgraph to be acceptedby the search operation

I Exclusion: Node type that accepts nodes that are not of thenot-node type positioned at the not-node in a subgraph.

I Times: Node type that allows for any graph structuredescribed by the structure in the subgraph positioned at thetime node in a subgraph to be accepted by the searchoperation one or times

I These cases are implemented by simply overriding any methodthat contains the equal logic that is used within the searchoperation

Page 14: Pcg2012 presentation

Benchmark: Method

I Ran worst case scenario search operations on increasinglycomplex graphs

I Worst case where every node in the graph should be visitedprior to completing the full search operation (number of nodesin matches is equal to the number of nodes in the graph)

I Implementations in C++, benchmarked against Ullmannsalgorithm and VF2 (both from the VFLib library) Timingusing standard C++ timing functions

Page 15: Pcg2012 presentation

Benchmark: Results

I Ullmann

I Our algorithm

I VF2

10 100

1000

10-5

10-4

10-3

10-2

10-1

100

Time (seconds

Nodes

I Faster at low node count, with tipping point between 100 and100 nodes

I Above 1000 nodes the implementation of our algorithm sticksclose to the VF2 implementation

Page 16: Pcg2012 presentation

Conclusion

I Subgraph searching allows to solve various problems incomputer science in a neat and fast way and allows forsearch/replace operations to be performed

I Our algorithm allows to solve the graph isomorphism problemin realtime while still offering full flexibility

I In the domain of game development this technique allows usto perform operations on graph-based game design structures

I Opening new possibilities to introduce new ways ofprocedurally generated games and procedurally generatedgameplay; game mechanics may be altered and introducedin-game

I Allowing for new games with more dynamic gameplay

Page 17: Pcg2012 presentation

Further Application and Research

I Focus on graph-based procedurally generated gamesI Graph transformation using neural network with input from

playerI Allowing for completely dynamic gameplay, gameplay is

adjusted according to the complete style of a player

I Graph isomorphism in parallel computing, CUDAimplementation, allowing for even faster search operations andeven more complex structures

Page 18: Pcg2012 presentation

Thank You Very Much

Thank you!

Marlon [email protected]

http://marlonetheredge.name/