Skip to content

Commit

Permalink
update readme and improve output
Browse files Browse the repository at this point in the history
  • Loading branch information
jessLryan committed Apr 8, 2024
1 parent 9beff07 commit 74d6bc4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 17 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# FPT Subgraph Counting Algorithm
An implementation of an algorithm described in [[1]](#1) for counting the number of times that one graph appears as a subgraph of the other.

The algorithm is expected to be efficient when the first graph is small, and the second graph has only a small proportion of high-degree vertices.

More formally, the algorithm is an FPT algorithm for labelled subgraph counting in classes of host graphs from the class of graphs with almost-bounded degree parameterised by the order
of the pattern graph.


### Input
The algorithm takes two inputs: a file containing the pattern graph data, and a file containing the host graph data.

The file for each graph must be a .txt file written in LAD format where the first line states the number of vertices in the graph, and the next $n$ lines state, for each vertex, its number of successor nodes, followed by the list of its successor nodes.

For example, the complete graph $K_4$ would be written as

4
3 1 2 3
3 0 2 3
3 0 1 3
3 0 1 2

### Output
The result is printed to the screen and contains the following information:

- **Date:** the date on which the code was run in the format year-month-day
- **Graph Statistics**: includes the following properties of each of the host and the pattern graph:
- **filepath**: the absolute filepath of the input file
- **graph type**: either HOST or PATTERN
- **order**: the number of vertices in the graph
- **number of edges**
- **average degree**

- **Number of high degree vertices**: the value of this parameter is optimised within the code
- **Maximum degree of remaining vertices**: the maximum degree of the host graph after the 'removal' of the high degree vertices
- **Run Status**: PASS if the number of copies of the graph is $>0$, FAIL if there are no copies, and INTERRUPTED if the program fails to complete for whatever reason
- **count** the number of labelled copies of the first graph in the second (null if interrupted)
- **runtime in milliseconds**

## References
<a id="1">[1]</a>
Ryan, Jessica Laurette,
_Parameterised Algorithms for Counting Subgraphs, Matchings, and Monochromatic Partitions_,
PhD Thesis,
2023
16 changes: 8 additions & 8 deletions src/main/java/algorithmRunner/RunResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public RunResult(Graph hostGraph,
@Override
public String toString() {
return "RunResult{" +
"date=" + date +
", patternGraphStatistics=" + patternGraphStatistics +
", hostGraphStatistics=" + hostGraphStatistics +
", numberOfHighDegreeVertices=" + numberOfHighDegreeVertices +
", maximumDegreeOfRemainingVertices=" + maximumDegreeOfRemainingVertices +
", status=" + status +
", count=" + count +
", runtimeInMilliseconds=" + runtimeInMilliseconds +
"date: " + date +
", pattern graph statistics: " + patternGraphStatistics +
", host graph statistics: " + hostGraphStatistics +
", number of high degree vertices parameter: " + numberOfHighDegreeVertices +
", maximum degree of remaining host graph: " + maximumDegreeOfRemainingVertices +
", run status: " + status +
", count: " + count +
", runtime in milliseconds: " + runtimeInMilliseconds +
'}';
}

Expand Down
19 changes: 10 additions & 9 deletions src/main/java/graph/GraphStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

public class GraphStatistics {

private final String filepath;
private final GraphType graphType;
private final int order;
private final int numEdges;
private final int averageDegree;
private final int maxDegree;
private final String filepath;
private final GraphType graphType;

public GraphStatistics(Graph graph, String filepath, GraphType graphType) {
order = graph.order();
Expand All @@ -18,15 +18,16 @@ public GraphStatistics(Graph graph, String filepath, GraphType graphType) {
this.graphType = graphType;
}


@Override
public String toString() {
return "Graph.GraphStatistics{" +
"order=" + order +
", numEdges=" + numEdges +
", averageDegree=" + averageDegree +
", maxDegree=" + maxDegree +
", filepath='" + filepath +
", graphType='" + graphType +
return "GraphStatistics{" +
"filepath: " + filepath + '\'' +
", graph type: " + graphType +
", order: " + order +
", number of edges: " + numEdges +
", average degree: " + averageDegree +
", maximum degree: " + maxDegree +
'}';
}
}

0 comments on commit 74d6bc4

Please sign in to comment.