All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.zabuzard.maglev.internal.algorithms.shortestpath.EmptyPath Maven / Gradle / Ivy

Go to download

Maglev is a library that provides fast and generic solutions for shortest path problems (SPP)

The newest version!
package io.github.zabuzard.maglev.internal.algorithms.shortestpath;

import io.github.zabuzard.maglev.external.algorithms.EdgeCost;
import io.github.zabuzard.maglev.external.algorithms.Path;
import io.github.zabuzard.maglev.external.graph.Edge;

import java.util.Collections;
import java.util.Iterator;

/**
 * Implementation of {@link Path} which represent an empty path. That is a path with no edges and only one node.
 *
 * @param  Type of the node
 * @param  Type of the edge
 *
 * @author Daniel Tischner {@literal }
 */
public final class EmptyPath> implements Path {
	/**
	 * The node this path consists of.
	 */
	private final N node;

	/**
	 * Creates a new empty path which consists only of the given node.
	 *
	 * @param node The node to add
	 */
	public EmptyPath(final N node) {
		this.node = node;
	}

	@SuppressWarnings("SuspiciousGetterSetter")
	@Override
	public N getDestination() {
		return node;
	}

	@SuppressWarnings("SuspiciousGetterSetter")
	@Override
	public N getSource() {
		return node;
	}

	@Override
	public double getTotalCost() {
		return 0.0;
	}

	@Override
	public Iterator> iterator() {
		return Collections.emptyListIterator();
	}

	@Override
	public int length() {
		return 0;
	}

	@Override
	public Iterator> reverseIterator() {
		return Collections.emptyListIterator();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy