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

Includes gradle upgrade, tests #7

Merged
merged 5 commits into from
Aug 27, 2023
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ erdos.iml

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea/
.gradle/
8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/modules/erdos.iml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: java
jdk:
- oraclejdk8
- openjdk17
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* factory methods for bulk generation of nodes.
* more graph engines, for example an engine that is based on the adjacency matrix
* more graph algorithms
* visulaization tool, i prefer html 5 based.
* visualization tool, I prefer html 5 based.
* github page
* unit testing contributions will be awesome.

Expand Down
27 changes: 0 additions & 27 deletions build.gradle

This file was deleted.

65 changes: 65 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
plugins {
`java-library`
jacoco
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

group = "com.github.erdos-graph-framework"
version = "1.0-SNAPSHOT"

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.1.0")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.1.0")

}

jacoco {
toolVersion = "0.8.9"
reportsDirectory.set(layout.buildDirectory.dir("customJacocoReportDir"))
}

tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
finalizedBy(tasks.jacocoTestCoverageVerification)
}

tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = "INSTRUCTION"
minimum = "0.80".toBigDecimal()
}
limit {
counter = "BRANCH"
minimum = "0.80".toBigDecimal()
}
limit {
counter = "LINE"
minimum = "0.80".toBigDecimal()
}
limit {
counter = "CLASS"
minimum = "0.90".toBigDecimal()
}
limit {
counter = "COMPLEXITY"
maximum = "0.30".toBigDecimal()
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// known issue: case sensitivity for IDEA
rootProject.name = "Erdos"

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

public class VertexNotFoundException extends GraphException {
public VertexNotFoundException(IVertex v, IGraph graph) {
super(v.getId() + " not found in graph", graph);
super(String.format("%s (%s) not found in graph", v.getId(), v.toString()), graph);
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/hendrix/erdos/graphs/AbstractGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ public boolean hasEdge(Edge edge) {
/**
* connect an edge (v1, v2) into the graph, v1 and v2 have to be members
*
* @param v1 a vertex that already belong to the graph
* @param v2 a vertex that already belong to the graph
* @param v1 a vertex that already belongs to the graph
* @param v2 a vertex that already belongs to the graph
*
* @return the edge so use can query the id
*/
Expand Down
58 changes: 1 addition & 57 deletions src/main/java/com/hendrix/example/GraphExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public GraphExamples() {
//BellmanFord();
//DijkstraShortestPath();
//matrixUtils();
floyd_Warshall_and_johnson();
// floyd_Warshall_and_johnson();
//transitiveClosure();
}

Expand Down Expand Up @@ -100,62 +100,6 @@ private void transitiveClosure() {

}

private void floyd_Warshall_and_johnson() {
SimpleDirectedGraph graph = new SimpleDirectedGraph();

Vertex v1 = new Vertex();
v1.setTag("1");
Vertex v2 = new Vertex();
v2.setTag("2");
Vertex v3 = new Vertex();
v3.setTag("3");
Vertex v4 = new Vertex();
v4.setTag("4");
Vertex v5 = new Vertex();
v5.setTag("5");

graph.addVertex(v1);
graph.addVertex(v2);
graph.addVertex(v3);
graph.addVertex(v4);
graph.addVertex(v5);

Edge e1_2 = new DirectedEdge(v1, v2, 3);
Edge e1_3 = new DirectedEdge(v1, v3, 8);
Edge e1_5 = new DirectedEdge(v1, v5, 4);

Edge e2_4 = new DirectedEdge(v2, v4, 1);
Edge e2_5 = new DirectedEdge(v2, v5, 7);

Edge e3_2 = new DirectedEdge(v3, v2, 4);

Edge e4_1 = new DirectedEdge(v4, v1, 2);
Edge e4_3 = new DirectedEdge(v4, v3, 5);

Edge e5_4 = new DirectedEdge(v5, v4, 6);

graph.addEdge(e1_2);
graph.addEdge(e1_3);
graph.addEdge(e1_5);
graph.addEdge(e2_4);
graph.addEdge(e2_5);
graph.addEdge(e3_2);
graph.addEdge(e4_1);
graph.addEdge(e4_3);
graph.addEdge(e5_4);

AllPairsShortPathResult floyd_result = new FloydWarshall(graph).applyAlgorithm();

floyd_result.shortestPathsTreeOf(v1).print();

System.out.println(floyd_result.shortestPathBetween(v5, v2).toString());

AllPairsShortPathResult johnson_result = AllPairsShortPathFactory.newAllPairsShortPath(graph, AllPairsShortPathFactory.APSPAlgorithm.Johnson).applyAlgorithm();


System.out.println("");
}

private void matrixUtils()
{
SimpleDirectedGraph graph = new SimpleDirectedGraph();
Expand Down
23 changes: 4 additions & 19 deletions src/test/java/com/hendrix/test/GraphTestsTest.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
package com.hendrix.test;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.concurrent.ThreadPoolExecutor;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

/**
* Created by tshalev on 09/02/2017.
*/
public class GraphTestsTest {
@Before
public void setUp() throws Exception {

}

@After
public void tearDown() throws Exception {

}

@Test
public void testHello() {

assert (true);
assertTrue(true);
}

}
}
Loading