Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
Release the version 1.0 of io.github.dustalov.maxmax
Browse files Browse the repository at this point in the history
  • Loading branch information
dustalov committed Dec 20, 2017
1 parent f3a2cde commit cf7c61a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 30 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sudo: false
language: java
jdk:
- oraclejdk8
- oraclejdk9
before_script:
- mvn versions:display-dependency-updates versions:display-plugin-updates
cache:
Expand Down
42 changes: 29 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<groupId>io.github.dustalov</groupId>
<artifactId>maxmax</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.0</version>
<packaging>jar</packaging>

<inceptionYear>2016</inceptionYear>
Expand All @@ -41,10 +41,6 @@
</developer>
</developers>

<prerequisites>
<maven>3.0</maven>
</prerequisites>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -63,12 +59,12 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.3.1</version>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -84,12 +80,30 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<DependencyConvergence/>
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
Expand All @@ -114,7 +128,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<version>3.1.0</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
Expand All @@ -136,8 +150,10 @@
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.github.dustalov.maxmax.Application</mainClass>
</transformer>
</transformers>
Expand All @@ -153,7 +169,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<version>3.0.0</version>
</plugin>
</plugins>
</reporting>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/github/dustalov/maxmax/ABCParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package io.github.dustalov.maxmax;

import org.jgrapht.UndirectedGraph;
import org.jgrapht.Graph;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleWeightedGraph;
import org.jgrapht.graph.builder.UndirectedWeightedGraphBuilderBase;
import org.jgrapht.graph.builder.GraphBuilder;

import java.util.stream.Stream;

interface ABCParser {
static UndirectedGraph<String, DefaultWeightedEdge> parse(Stream<String> stream) {
final UndirectedWeightedGraphBuilderBase<String, DefaultWeightedEdge, ? extends SimpleWeightedGraph<String, DefaultWeightedEdge>, ?> builder = SimpleWeightedGraph.builder(DefaultWeightedEdge.class);
static Graph<String, DefaultWeightedEdge> parse(Stream<String> stream) {
final GraphBuilder<String, DefaultWeightedEdge, ? extends SimpleWeightedGraph<String, DefaultWeightedEdge>> builder = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class);

stream.forEach(line -> {
final String[] split = line.split("\t");
Expand All @@ -35,6 +35,6 @@ static UndirectedGraph<String, DefaultWeightedEdge> parse(Stream<String> stream)
builder.addEdge(split[0], split[1], Double.valueOf(split[2]));
});

return builder.buildUnmodifiable();
return builder.build();
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/github/dustalov/maxmax/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package io.github.dustalov.maxmax;

import org.apache.commons.cli.*;
import org.jgrapht.UndirectedGraph;
import org.jgrapht.Graph;
import org.jgrapht.graph.DefaultWeightedEdge;

import java.io.BufferedWriter;
Expand Down Expand Up @@ -48,7 +48,7 @@ public static void main(String[] args) throws IOException {
System.exit(1);
}

final UndirectedGraph<String, DefaultWeightedEdge> graph = parse(cmd.getOptionValue("in"), ABCParser::parse);
final Graph<String, DefaultWeightedEdge> graph = parse(cmd.getOptionValue("in"), ABCParser::parse);
final MaxMax<String> maxmax = new MaxMax<>(graph);
maxmax.run();
write(cmd.getOptionValue("out"), maxmax);
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/io/github/dustalov/maxmax/MaxMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

package io.github.dustalov.maxmax;

import org.jgrapht.DirectedGraph;
import org.jgrapht.Graph;
import org.jgrapht.Graphs;
import org.jgrapht.UndirectedGraph;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DefaultWeightedEdge;
Expand All @@ -34,12 +33,12 @@
* @param <V> node class.
*/
public class MaxMax<V> implements Runnable {
private final UndirectedGraph<V, DefaultWeightedEdge> graph;
private final DirectedGraph<V, DefaultEdge> digraph;
private final Graph<V, DefaultWeightedEdge> graph;
private final Graph<V, DefaultEdge> digraph;
private final Map<V, Set<V>> maximals;
private final Map<V, Boolean> roots;

public MaxMax(UndirectedGraph<V, DefaultWeightedEdge> graph) {
public MaxMax(Graph<V, DefaultWeightedEdge> graph) {
this.graph = graph;
this.digraph = new DefaultDirectedGraph<>(DefaultEdge.class);
this.graph.vertexSet().forEach(digraph::addVertex);
Expand Down Expand Up @@ -82,11 +81,11 @@ public void run() {
});
}

public UndirectedGraph<V, DefaultWeightedEdge> getGraph() {
public Graph<V, DefaultWeightedEdge> getGraph() {
return graph;
}

public DirectedGraph<V, DefaultEdge> getDigraph() {
public Graph<V, DefaultEdge> getDigraph() {
return digraph;
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/io/github/dustalov/maxmax/MaxMaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package io.github.dustalov.maxmax;

import org.jgrapht.UndirectedGraph;
import org.jgrapht.Graph;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleWeightedGraph;
import org.junit.Before;
Expand All @@ -31,7 +31,7 @@
import static org.junit.Assert.assertEquals;

public class MaxMaxTest {
final static UndirectedGraph<String, DefaultWeightedEdge> GRAPH1 = SimpleWeightedGraph.<String, DefaultWeightedEdge>builder(DefaultWeightedEdge.class).
final static Graph<String, DefaultWeightedEdge> GRAPH1 = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
addVertices("r", "s", "u", "v", "t", "w", "x").
addEdge("r", "s", 3).
addEdge("r", "v", 1).
Expand All @@ -56,7 +56,7 @@ public class MaxMaxTest {
new HashSet<>(Arrays.asList("w", "t", "x"))
)));

final static UndirectedGraph<String, DefaultWeightedEdge> GRAPH2 = SimpleWeightedGraph.<String, DefaultWeightedEdge>builder(DefaultWeightedEdge.class).
final static Graph<String, DefaultWeightedEdge> GRAPH2 = SimpleWeightedGraph.<String, DefaultWeightedEdge>createBuilder(DefaultWeightedEdge.class).
addVertices("a", "b", "c", "d", "e").
addEdge("a", "b", 3).
addEdge("b", "c", 1).
Expand Down

0 comments on commit cf7c61a

Please sign in to comment.