From a0de7d8ac3c51f9fceae7545b51d4e382f11180a Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 25 Jun 2023 14:34:31 +0200 Subject: [PATCH] Add getNumberOfEdges() and getNumberOfSignatures() to get insight into Network objects --- .../pgpainless/wot/dijkstra/sq/Network.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/wot-dijkstra/src/main/java/org/pgpainless/wot/dijkstra/sq/Network.java b/wot-dijkstra/src/main/java/org/pgpainless/wot/dijkstra/sq/Network.java index 1b7b21aa..7d650435 100644 --- a/wot-dijkstra/src/main/java/org/pgpainless/wot/dijkstra/sq/Network.java +++ b/wot-dijkstra/src/main/java/org/pgpainless/wot/dijkstra/sq/Network.java @@ -96,6 +96,36 @@ public class Network { return new HashMap<>(reverseEdges); } + /** + * Return the total number of edges on the network. + * + * @return number of edges + */ + public int getNumberOfEdges() { + int num = 0; + for (List outEdges : edges.values()) { + num += outEdges.size(); + } + return num; + } + + /** + * Return the total number of signatures the network comprises. + * + * @return number of signatures + */ + public int getNumberOfSignatures() { + int num = 0; + for (List edgesPerIssuer : edges.values()) { + for (CertificationSet edge : edgesPerIssuer) { + for (List sigsPerDatum : edge.getCertifications().values()) { + num += sigsPerDatum.size(); + } + } + } + return num; + } + /** * Return the {@link ReferenceTime} which was used when creating the {@link Network}. *