Compare commits

...

1 Commits
0.1.2 ... 0.1.3

Author SHA1 Message Date
William Jacobs
458cdd3ddd Fixed size calculation in optimizeForestEdges()
This fixes the code in ConnGraph.optimizeForestEdges() that computes the resulting size after combining two Euler tour trees into one. Technically, the old behavior was still correct, but only by accident; this change is still kind of a bug fix.
2019-03-18 13:21:26 -04:00
5 changed files with 8 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.btrekkie.connectivity</groupId>
<artifactId>dynamic-connectivity</artifactId>
<version>0.1.2</version>
<version>0.1.3</version>
<name>dynamic-connectivity</name>
<description>Data structure for dynamic connectivity in undirected graphs</description>
<build>

View File

@@ -1073,20 +1073,21 @@ public class ConnGraph {
EulerTourVertex lowerVertex1 = vertex;
EulerTourVertex lowerVertex2 = edge.vertex2;
for (int lowerLevel = level - 1; lowerLevel > 0; lowerLevel--) {
int size = 0;
// Compute the total size if we combine the Euler tour trees
int combinedSize = 1;
if (lowerVertex1.lowerVertex != null) {
size = lowerVertex1.lowerVertex.arbitraryVisit.root().size;
combinedSize += lowerVertex1.lowerVertex.arbitraryVisit.root().size;
} else {
size = 1;
combinedSize++;
}
if (lowerVertex2.lowerVertex != null) {
size += lowerVertex2.lowerVertex.arbitraryVisit.root().size;
combinedSize += lowerVertex2.lowerVertex.arbitraryVisit.root().size;
} else {
size++;
combinedSize++;
}
// X EulerTourVertices = (2 * X - 1) EulerTourNodes
if (size > 2 * (1 << lowerLevel) - 1) {
if (combinedSize > 2 * (1 << lowerLevel) - 1) {
break;
}

Binary file not shown.