This commit is contained in:
navid.sassan 2020-11-08 12:19:40 +01:00
parent 65125e61d6
commit e8700f39ef
7 changed files with 274 additions and 274 deletions

206
07/gradlew.bat vendored
View File

@ -1,103 +1,103 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,54 +1,54 @@
package ch.zhaw.ads;
import java.util.*;
public class AdjListGraph<N extends Node,E extends Edge>
implements Graph<N, E> {
private final List<N> nodes = new LinkedList<N>();
private final Class nodeClazz;
private final Class edgeClazz;
public AdjListGraph(Class nodeClazz, Class edgeClazz) {
this.nodeClazz = nodeClazz;
this.edgeClazz = edgeClazz;
}
// füge Knoten hinzu, gebe alten zurück falls Knoten schon existiert
public N addNode(String name) throws Throwable {
N node = findNode(name);
if (node == null) {
node = (N) nodeClazz.newInstance();
node.setName(name);
nodes.add(node);
}
return node;
}
// füge gerichtete Kante hinzu
public void addEdge(String source, String dest, double weight) throws Throwable {
N src = addNode(source);
N dst = addNode(dest);
try {
E edge = (E) edgeClazz.newInstance();
edge.setDest(dst);
edge.setWeight(weight);
src.addEdge(edge);
} catch (Exception e) {}
}
// finde den Knoten anhand seines Namens
public N findNode(String name) {
for (N node : nodes) {
if (node.getName().equals(name)) {
return node;
}
}
return null;
}
// Iterator über alle Knoten
public Iterable<N> getNodes() {
return nodes;
}
import java.util.*;
public class AdjListGraph<N extends Node,E extends Edge>
implements Graph<N, E> {
private final List<N> nodes = new LinkedList<N>();
private final Class nodeClazz;
private final Class edgeClazz;
public AdjListGraph(Class nodeClazz, Class edgeClazz) {
this.nodeClazz = nodeClazz;
this.edgeClazz = edgeClazz;
}
// füge Knoten hinzu, gebe alten zurück falls Knoten schon existiert
public N addNode(String name) throws Throwable {
N node = findNode(name);
if (node == null) {
node = (N) nodeClazz.newInstance();
node.setName(name);
nodes.add(node);
}
return node;
}
// füge gerichtete Kante hinzu
public void addEdge(String source, String dest, double weight) throws Throwable {
N src = addNode(source);
N dst = addNode(dest);
try {
E edge = (E) edgeClazz.newInstance();
edge.setDest(dst);
edge.setWeight(weight);
src.addEdge(edge);
} catch (Exception e) {}
}
// finde den Knoten anhand seines Namens
public N findNode(String name) {
for (N node : nodes) {
if (node.getName().equals(name)) {
return node;
}
}
return null;
}
// Iterator über alle Knoten
public Iterable<N> getNodes() {
return nodes;
}
}

View File

@ -1,36 +1,36 @@
package ch.zhaw.ads;
class DijkstraNode<E> extends Node<E> implements Comparable<DijkstraNode> {
boolean mark;
DijkstraNode<E> prev;
double dist;
public double getDist() {
return dist;
}
public void setDist(double dist) {
this.dist = dist;
}
public void setMark(boolean m) {
mark = m;
}
public boolean getMark() {
return mark;
}
public void setPrev(DijkstraNode<E> p) {
prev = p;
}
public DijkstraNode<E> getPrev() {
return prev;
}
public int compareTo(DijkstraNode n) {
// TODO: implement
return 0;
}
}
class DijkstraNode<E> extends Node<E> implements Comparable<DijkstraNode> {
boolean mark;
DijkstraNode<E> prev;
double dist;
public double getDist() {
return dist;
}
public void setDist(double dist) {
this.dist = dist;
}
public void setMark(boolean m) {
mark = m;
}
public boolean getMark() {
return mark;
}
public void setPrev(DijkstraNode<E> p) {
prev = p;
}
public DijkstraNode<E> getPrev() {
return prev;
}
public int compareTo(DijkstraNode n) {
// TODO: implement
return 0;
}
}

View File

@ -1,20 +1,20 @@
package ch.zhaw.ads;
public class Edge<N>
{
protected N dest; // Zielknoten der Kante
protected double weight; // Kantengewicht
public Edge() {}
public Edge(N dest, double weight) {
this.dest = dest;
this.weight = weight;
}
public void setDest(N node) {this.dest = node;}
public N getDest() {return dest;}
public void setWeight(double w) {this.weight = w;}
double getWeight() {return weight;}
}
public class Edge<N>
{
protected N dest; // Zielknoten der Kante
protected double weight; // Kantengewicht
public Edge() {}
public Edge(N dest, double weight) {
this.dest = dest;
this.weight = weight;
}
public void setDest(N node) {this.dest = node;}
public N getDest() {return dest;}
public void setWeight(double w) {this.weight = w;}
double getWeight() {return weight;}
}

View File

@ -1,20 +1,20 @@
package ch.zhaw.ads;
import java.util.*;
public interface Graph<N,E> {
// füge Knoten hinzu, tue nichts, falls Knoten schon existiert
N addNode (String name) throws Throwable;
// finde den Knoten anhand seines Namens
N findNode(String name);
// Iterator über alle Knoten des Graphen
Iterable<N> getNodes();
// füge gerichtete und gewichtete Kante hinzu
void addEdge(String source, String dest, double weight) throws Throwable ;
}
import java.util.*;
public interface Graph<N,E> {
// füge Knoten hinzu, tue nichts, falls Knoten schon existiert
N addNode (String name) throws Throwable;
// finde den Knoten anhand seines Namens
N findNode(String name);
// Iterator über alle Knoten des Graphen
Iterable<N> getNodes();
// füge gerichtete und gewichtete Kante hinzu
void addEdge(String source, String dest, double weight) throws Throwable ;
}

View File

@ -1,34 +1,34 @@
package ch.zhaw.ads;
import java.util.*;
public class Node<E> {
protected String name; // Name
protected List<E> edges; // Kanten
public Node() {
edges = new LinkedList<E>();
}
public Node(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Iterable<E> getEdges() {
return edges;
}
public void addEdge(E edge) {
edges.add(edge);
}
}
import java.util.*;
public class Node<E> {
protected String name; // Name
protected List<E> edges; // Kanten
public Node() {
edges = new LinkedList<E>();
}
public Node(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Iterable<E> getEdges() {
return edges;
}
public void addEdge(E edge) {
edges.add(edge);
}
}

View File

@ -1,14 +1,14 @@
Winterthur Zürich 25
Zürich Bern 126
Zürich Genf 277
Zürich Luzern 54
Zürich Chur 121
Zürich Berikon 16
Bern Genf 155
Genf Lugano 363
Lugano Luzern 206
Lugano Chur 152
Chur Luzern 146
Luzern Bern 97
Bern Berikon 102
Winterthur Zürich 25
Zürich Bern 126
Zürich Genf 277
Zürich Luzern 54
Zürich Chur 121
Zürich Berikon 16
Bern Genf 155
Genf Lugano 363
Lugano Luzern 206
Lugano Chur 152
Chur Luzern 146
Luzern Bern 97
Bern Berikon 102
Luzern Berikon 41