Tutorial¶
First, import uclasm, the subgraph matching library.
>>> import uclasm
You will need to express your template and world graphs as edgelist files such as these.
template.csv¶
Source,Target,eType
t1,t2,1
t2,t1,2
world.csv¶
Source,Target,eType
w1,w2,2
w1,w4,2
w2,w3,1
w3,w2,2
w4,w3,1
Load your template and world graphs from the edgelist files.
>>> tmplt = uclasm.load_edgelist("template.csv",
... file_source_col="Source",
... file_target_col="Target",
... file_channel_col="eType")
>>> world = uclasm.load_edgelist("world.csv",
... file_source_col="Source",
... file_target_col="Target",
... file_channel_col="eType")
Create a matching problem to search for instances of the template in the world.
>>> smp = uclasm.MatchingProblem(tmplt, world)
Run various filters to reduce the search space.
>>> uclasm.nodewise_cost_bound(smp)
View the state of the matching problem.
>>> print(smp)
t1 has 2 candidates: w2, w4
1 template nodes have 1 candidate: t2