1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-25 04:17:59 +01:00

Add getNumberOfEdges() and getNumberOfSignatures() to get insight into Network objects

This commit is contained in:
Paul Schaub 2023-06-25 14:34:31 +02:00
parent 6ec160835c
commit b98707320d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -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<CertificationSet> 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<CertificationSet> edgesPerIssuer : edges.values()) {
for (CertificationSet edge : edgesPerIssuer) {
for (List<Certification> sigsPerDatum : edge.getCertifications().values()) {
num += sigsPerDatum.size();
}
}
}
return num;
}
/**
* Return the {@link ReferenceTime} which was used when creating the {@link Network}.
*