de.tsl2.nano.vnet.routing.RoutingAStar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.vnet Show documentation
Show all versions of tsl2.nano.vnet Show documentation
TSL2 Framework VirtualNetwork (Generic parallelized Network-Mechanism providing implementations for: NeuronalNetwork, Routing, Workflow)
The newest version!
/*
* File: $HeadURL$
* Id : $Id$
*
* created by: Thomas Schneider, Thomas Schneider
* created on: Dec 2, 2012
*
* Copyright: (c) Thomas Schneider 2012, all rights reserved
*/
package de.tsl2.nano.vnet.routing;
import de.tsl2.nano.core.ManagedException;
import de.tsl2.nano.structure.IConnection;
import de.tsl2.nano.vnet.Connection;
import de.tsl2.nano.vnet.Node;
/**
* Implements the {@link #connect(Node, Node, float)} method of {@link AbstractRoutingAStar} to create a new connection
* between a node and its successor.
*
* @author Thomas Schneider, Thomas Schneider
* @version $Revision$
*/
public class RoutingAStar extends AbstractRoutingAStar {
static final Float TRACK_MARKER = 1000000f;
/**
* {@inheritDoc}
*/
@Override
protected Connection connect(Node currentNode,
Node successor,
float f) {
try {
//connect copies of both nodes in both directions
Node n1 = currentNode.clone();
Node n2 = successor.clone();
//connect the way back with a sign to identify it as a track
n2.connect(n1, TRACK_MARKER + currentNode.getConnection(successor).getDescriptor());
//return the requested connection
return (Connection) n1.connect(n2, f);
} catch (CloneNotSupportedException e) {
ManagedException.forward(e);
return null;
}
}
@Override
protected boolean isTrack(IConnection con) {
return con.getDescriptor().compareTo(TRACK_MARKER) > 0;
}
/**
* {@inheritDoc}
*/
@Override
protected void removeTrackMarker(IConnection connection) {
((Connection)connection).setDescriptor(connection.getDescriptor() - TRACK_MARKER);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy