From 74d6bc41791baebfc9d737e99db547a51ed83369 Mon Sep 17 00:00:00 2001 From: Jess <122939887+jessLryan@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:55:30 +0100 Subject: [PATCH] update readme and improve output --- README.md | 45 ++++++++++++++++++++ src/main/java/algorithmRunner/RunResult.java | 16 +++---- src/main/java/graph/GraphStatistics.java | 19 +++++---- 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..afe1f9f --- /dev/null +++ b/README.md @@ -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 +[1] +Ryan, Jessica Laurette, +_Parameterised Algorithms for Counting Subgraphs, Matchings, and Monochromatic Partitions_, +PhD Thesis, +2023 \ No newline at end of file diff --git a/src/main/java/algorithmRunner/RunResult.java b/src/main/java/algorithmRunner/RunResult.java index ee95e46..c313ddf 100644 --- a/src/main/java/algorithmRunner/RunResult.java +++ b/src/main/java/algorithmRunner/RunResult.java @@ -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 + '}'; } diff --git a/src/main/java/graph/GraphStatistics.java b/src/main/java/graph/GraphStatistics.java index 6dcc931..c8c1415 100644 --- a/src/main/java/graph/GraphStatistics.java +++ b/src/main/java/graph/GraphStatistics.java @@ -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(); @@ -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 + '}'; } } \ No newline at end of file