PAMI.subgraphMining.topK package
Submodules
PAMI.subgraphMining.topK.DFSCode module
- class PAMI.subgraphMining.topK.DFSCode.DfsCode[source]
Bases:
object- add(ee)[source]
Adds an extended edge to the DFSCode object.
- Parameters:
ee (ExtendedEdge) – The extended edge to add.
- containEdge(v1, v2)[source]
Checks if an edge between vertices v1 and v2 is present.
- Parameters:
v1 (int) – The first vertex of the edge.
v2 (int) – The second vertex of the edge.
- Returns:
True if the edge is present, False otherwise.
- Return type:
bool
- getAllVLabels()[source]
Retrieves all vertex labels from the extended edge list.
- Returns:
A list of vertex labels.
- Return type:
list
- getAt(index)[source]
Retrieves the extended edge at the specified index.
- Parameters:
index (int) – The index of the extended edge to retrieve.
- Returns:
The extended edge at the specified index.
- Return type:
- getEeList()[source]
Retrieves the extended edge list.
- Returns:
A list of ExtendedEdge objects.
- Return type:
list
- getRightMost()[source]
Retrieves the rightmost vertex.
- Returns:
The index of the rightmost vertex.
- Return type:
int
- getRightMostPath()[source]
Retrieves the rightmost path.
- Returns:
A list containing the vertices on the rightmost path.
- Return type:
list
- isEmpty()[source]
Checks if the DFSCode object is empty.
- Returns:
True if the DFSCode object is empty, False otherwise.
- Return type:
bool
PAMI.subgraphMining.topK.DFSThread module
- class PAMI.subgraphMining.topK.DFSThread.DfsThread(graphDb, candidates, minSup, tkgInstance)[source]
Bases:
ThreadA thread class for performing DFS-based subgraph mining on a set of candidates.
- Parameters:
graphDb (GraphDatabase) – The graph database containing the input graphs.
candidates (Queue) – A queue containing candidate subgraphs to be mined.
minSup (int) – The minimum support threshold for frequent subgraph mining.
tkgInstance (TKGInstance) – An instance of the Top-K Graphs (TKG) algorithm for dynamic subgraph mining.
- run()[source]
Runs the DFS-based subgraph mining process on the candidate subgraphs.
This method is invoked when the thread is started using the start() method.
Within the mining loop: - Retrieves a candidate subgraph from the candidates queue. - Checks if the candidate’s support meets the minimum support threshold. - If the support is sufficient, invokes the gspanDynamicDFS method of the TKGInstance
to perform dynamic DFS-based subgraph mining with the candidate’s DFS code, the graph database, and the set of graph IDs associated with the candidate.
This method continues to run until the candidates queue is empty or until a candidate with insufficient support is encountered.
PAMI.subgraphMining.topK.abstract module
PAMI.subgraphMining.topK.edge module
PAMI.subgraphMining.topK.extendedEdge module
PAMI.subgraphMining.topK.frequentSubgraph module
PAMI.subgraphMining.topK.graph module
- class PAMI.subgraphMining.topK.graph.Graph(iD, vMap=None, dfsCode=None)[source]
Bases:
objectRepresents a graph structure composed of vertices and edges.
- EMPTY_VERTEX_LIST
An empty list used as a default value for vertex lists.
- Type:
list
- EMPTY_INTEGER_ARRAY
An empty list used as a default value for integer arrays.
- Type:
list
- EMPTY_INTEGER_ARRAY = []
- EMPTY_VERTEX_LIST = []
PAMI.subgraphMining.topK.sparseTriangularMatrix module
- class PAMI.subgraphMining.topK.sparseTriangularMatrix.SparseTriangularMatrix[source]
Bases:
objectRepresents a sparse triangular matrix structure for storing counts or support values.
- matrix
A dictionary representing the sparse matrix structure.
- Type:
dict
- getSupportForItems(i, j)[source]
Retrieves the support value for items at positions (i, j) in the matrix.
- incrementCount(i, j)[source]
Increments the count or support value at the position (i, j) in the matrix.
PAMI.subgraphMining.topK.tkg module
- class PAMI.subgraphMining.topK.tkg.TKG(iFile, k, maxNumberOfEdges=inf, outputSingleVertices=True, outputGraphIds=False)[source]
Bases:
_TKG- DYNAMIC_SEARCH = True
- EDGE_COUNT_PRUNING = True
- ELIMINATE_INFREQUENT_EDGE_LABELS = True
- ELIMINATE_INFREQUENT_VERTEX_PAIRS = True
- ELIMINATE_INFREQUENT_VERTICES = True
- THREADED_DYNAMIC_SEARCH = True
- gSpan(graphDB, outputFrequentVertices)[source]
The main gSpan function to find frequent subgraphs. :param graphDb: The database of graphs to mine. :param outputFrequentVertices: Boolean indicating whether to output single vertices as subgraphs.
- getKSubgraphs()[source]
Return the formatted subgraphs as a single string with correct formatting and newlines.
- getSubgraphsList()[source]
Creates a copy of the queue’s contents without emptying the original queue.
- get_label(label_char)[source]
Maps a character vertex label to a unique integer. If the label is already mapped, returns the existing integer. Otherwise, assigns a new integer to the label.
- mine()[source]
This Python function starts a mining process on a graph database, calculates runtime, pattern count, and memory usage metrics.
- readGraphs(path)[source]
Reads graph data from a file and constructs a list of graphs with vertices and edges. Handles character vertex labels by mapping them to unique integers. Edge labels are assumed to be integers.