Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AISS L7 G02 - University work #1073

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ private boolean containsShortestOddHole(Graph<V, E> g, Set<V> X)
GraphPath<V, E> rx3y2 = getPathAvoidingX(g, x3, y2, X);
GraphPath<V, E> rx1y2 = getPathAvoidingX(g, x1, y2, X);
if (rx3y1 != null && rx3y2 != null && rx1y2 != null
&& rx2y1.getLength() == (n = rx1y1.getLength() + 1)
&& rx2y1.getLength() == (n = rx1y1.getLength() + 1.)
&& n == rx1y2.getLength() && rx3y1.getLength() >= n
&& rx3y2.getLength() >= n)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static <V, E> GraphPath<V, E> simpleCycleToGraphPath(Graph<V, E> graph, L
// traverse
List<E> edges = new ArrayList<>();
double weight = 0d;
E e = cycle.stream().findAny().get();
E e = cycle.stream().findAny().orElse(null);
edges.add(e);
weight += graph.getEdgeWeight(e);
V start = graph.getEdgeSource(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public double predict(V u, V v)
int du = graph.outDegreeOf(u);
int dv = graph.outDegreeOf(v);

return du * dv;
return (double) du * dv;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public double predict(V u, V v)
Set<V> intersection = new HashSet<>(gu);
intersection.retainAll(gv);

return (double) intersection.size() / Math.sqrt(du * dv);
return (double) intersection.size() / Math.sqrt((double) (du * dv));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public Matching<V, E> getMatching()
List<E> allEdges = new ArrayList<>(graph.edgeSet());
if (normalizeEdgeCosts) {
allEdges.sort((e1, e2) -> {
double degreeE1 = graph.degreeOf(graph.getEdgeSource(e1))
double degreeE1 = (double) graph.degreeOf(graph.getEdgeSource(e1))
+ graph.degreeOf(graph.getEdgeTarget(e1));
double degreeE2 = graph.degreeOf(graph.getEdgeSource(e2))
double degreeE2 = (double) graph.degreeOf(graph.getEdgeSource(e2))
+ graph.degreeOf(graph.getEdgeTarget(e2));
return comparator
.compare(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private Matching<V, E> run()
int i = 1;
while (!visibleVertex.isEmpty()) {
// find vertex arbitrarily
V x = visibleVertex.stream().findAny().get();
V x = visibleVertex.stream().findAny().orElse(null);

// grow path from x
while (x != null) {
Expand Down Expand Up @@ -240,7 +240,7 @@ private Matching<V, E> runWithHeuristics()
// run algorithm
while (!visibleVertex.isEmpty()) {
// find vertex arbitrarily
V x = visibleVertex.stream().findAny().get();
V x = visibleVertex.stream().findAny().orElse(null);

// grow path from x
LinkedList<E> path = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ && containsEdge(v, q, graph, indexList))
{
R[u] = L[u];
L[u] = p;
R[v] = R[v];
// R[v] = R[v];
L[v] = q;
L[p] = L[p];
// L[p] = L[p];
R[p] = u;
L[q] = R[q];
R[q] = v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public long getMaxSink2ALlArcNum() {
* @return minimum number of nodes this network can contain.
*/
public long getMinimumArcNum() {
return getTransshipNodeNum() + Math.max(getSourceNum(), getSinkNum());
return (long) (getTransshipNodeNum() + Math.max(getSourceNum(), getSinkNum()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public ClosestFirstIterator(
initialized = true;
if (!crossComponentTraversal) {
// prime the heap by processing the first start vertex
hasNext();
hasNext();
Iterator<V> iter = startVertices.iterator();
if (iter.hasNext()) {
// discard the first since we already primed it above
Expand Down
2 changes: 1 addition & 1 deletion jgrapht-core/src/main/java/overview.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<body bgcolor="white">
<b>JGraphT</b> is a free Java class library that provides mathematical graph-theory
<strong>JGraphT</strong> is a free Java class library that provides mathematical graph-theory
objects and algorithms. This is an open-source java graph library that supports a
rich gallery of graphs and is designed to be powerful, extensible and easy to use.
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static void main(String[] args)
// @example:findVertex:begin
URI start = hrefGraph
.vertexSet().stream().filter(uri -> uri.getHost().equals("www.jgrapht.org")).findAny()
.get();
.orElse(null);
// @example:findVertex:end

// @example:traverse:end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void writeObject(ObjectOutputStream oos)
V v = e.nodeV();
oos.writeObject(u);
oos.writeObject(v);
oos.writeObject(valueGraph.edgeValue(u, v).get());
oos.writeObject(valueGraph.edgeValue(u, v).orElse(null));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private void writeObject(ObjectOutputStream oos)
V v = e.nodeV();
oos.writeObject(u);
oos.writeObject(v);
oos.writeObject(valueGraph.edgeValue(u, v).get());
oos.writeObject(valueGraph.edgeValue(u, v).orElse(null));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private void exportNormalizedLaplacianMatrix(Graph<V, E> g, Writer writer)

for (V to : neighbors) {
String toName = getVertexId(to);
double value = -1 / Math.sqrt(g.degreeOf(from) * g.degreeOf(to));
double value = -1 / Math.sqrt(g.degreeOf(from) * (double) g.degreeOf(to));
exportEntry(out, fromName, toName, Double.toString(value));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public long degreeOf(Integer vertex)
if (inIncidenceMatrix == null) {
indexIncomingEdges();
}
return outIncidenceMatrix.nonZeros(vertex) + inIncidenceMatrix.nonZeros(vertex);
return (long) (outIncidenceMatrix.nonZeros(vertex) + inIncidenceMatrix.nonZeros(vertex));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ E> SuccinctDirectedGraph(final Graph<Integer, E> graph, final boolean incomingEd
+ Integer.MAX_VALUE);

cumulativeOutdegrees = new EliasFanoIndexedMonotoneLongBigList(
n + 1, m, new CumulativeDegrees(n, graph::outDegreeOf));
(long) (n + 1), m, new CumulativeDegrees(n, graph::outDegreeOf));
assert cumulativeOutdegrees.getLong(cumulativeOutdegrees.size64() - 1) == m;

successors = new EliasFanoIndexedMonotoneLongBigList(
Expand All @@ -131,7 +131,7 @@ E> SuccinctDirectedGraph(final Graph<Integer, E> graph, final boolean incomingEd

if (incomingEdgesSupport) {
cumulativeIndegrees = new EliasFanoMonotoneLongBigList(
n + 1, m, new CumulativeDegrees(n, graph::inDegreeOf));
(long) (n + 1), m, new CumulativeDegrees(n, graph::inDegreeOf));
assert cumulativeIndegrees.getLong(cumulativeIndegrees.size64() - 1) == m;

predecessors = new EliasFanoIndexedMonotoneLongBigList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public <E> SuccinctIntDirectedGraph(
+ Integer.MAX_VALUE);

cumulativeOutdegrees = new EliasFanoIndexedMonotoneLongBigList(
n + 1, m, new CumulativeDegrees(n, graph::outDegreeOf));
(long) (n + 1), m, new CumulativeDegrees(n, graph::outDegreeOf));
assert cumulativeOutdegrees.getLong(cumulativeOutdegrees.size64() - 1) == m;

successors = new EliasFanoIndexedMonotoneLongBigList(
Expand All @@ -127,7 +127,7 @@ public <E> SuccinctIntDirectedGraph(

if (incomingEdgesSupport) {
cumulativeIndegrees = new EliasFanoMonotoneLongBigList(
n + 1, m, new CumulativeDegrees(n, graph::inDegreeOf));
(long) (n + 1), m, new CumulativeDegrees(n, graph::inDegreeOf));
assert cumulativeIndegrees.getLong(cumulativeIndegrees.size64() - 1) == m;

predecessors = new EliasFanoIndexedMonotoneLongBigList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public <E> SuccinctIntUndirectedGraph(final Graph<Integer, E> graph)
+ Integer.MAX_VALUE);

cumulativeOutdegrees = new EliasFanoIndexedMonotoneLongBigList(
n + 1, m, new CumulativeDegrees<>(graph, true, iterables::edgesOf));
(long) (n + 1), m, new CumulativeDegrees<>(graph, true, iterables::edgesOf));
cumulativeIndegrees = new EliasFanoMonotoneLongBigList(
n + 1, m, new CumulativeDegrees<>(graph, false, iterables::edgesOf));
(long) (n + 1), m, new CumulativeDegrees<>(graph, false, iterables::edgesOf));
assert cumulativeOutdegrees.getLong(cumulativeOutdegrees.size64() - 1) == m;
assert cumulativeIndegrees.getLong(cumulativeIndegrees.size64() - 1) == m;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public <E> SuccinctUndirectedGraph(final Graph<Integer, E> graph)
+ Integer.MAX_VALUE);

cumulativeOutdegrees = new EliasFanoIndexedMonotoneLongBigList(
n + 1, m, new CumulativeDegrees<>(graph, true, iterables::edgesOf));
(long) (n + 1), m, new CumulativeDegrees<>(graph, true, iterables::edgesOf));
cumulativeIndegrees = new EliasFanoMonotoneLongBigList(
n + 1, m, new CumulativeDegrees<>(graph, false, iterables::edgesOf));
(long) (n + 1), m, new CumulativeDegrees<>(graph, false, iterables::edgesOf));
assert cumulativeOutdegrees.getLong(cumulativeOutdegrees.size64() - 1) == m;
assert cumulativeIndegrees.getLong(cumulativeIndegrees.size64() - 1) == m;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public Set<LongLongPair> edgeSet()
@Override
public int degreeOf(final Long vertex)
{
final long d = inDegreeOf(vertex) + outDegreeOf(vertex);
final long d =(long) (inDegreeOf(vertex) + outDegreeOf(vertex));
if (d > Integer.MAX_VALUE)
throw new ArithmeticException();
return (int) d;
Expand Down
31 changes: 30 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<main.basedir>${project.basedir}</main.basedir>
<sonar.projectKey>AISS-2021-L7-G02_jgrapht</sonar.projectKey>
<sonar.moduleKey>${artifactId}</sonar.moduleKey>
<sonar.organization>aiss-2021-l7-g02</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.language>java</sonar.language>
<jacoco.version>0.8.6</jacoco.version>
<test.jacoco.includeNoLocationClasses>true</test.jacoco.includeNoLocationClasses>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -309,7 +317,28 @@
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</plugin>
</plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<phase>test-compile</phase>
</execution>
<execution>
<id>report</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<modules>
Expand Down