public WeightedMapGraph(List<Edge> edges)
	{
		graph = new HashMap<>();
		directionKeys = new LinkedHashSet<>();
		for (final Edge edge : edges)
		{
			// checks for bad values
			if (edge.getFromNode().getID() < 0 || edge.getToNode().getID() < 0 || edge.getLength() < 0 || edge.getWeight() < 0
					|| edge.getLength() == Integer.MAX_VALUE || edge.getWeight() == Integer.MAX_VALUE)
			{
				continue;
			}
			if (graph.containsKey(edge.getFromNode()))
			{
				graph.get(edge.getFromNode()).add(edge);
			} else
			{
				graph.put(edge.getFromNode(), new HashSet<Edge>() {

					
					{
						add(edge);
					}
				});
			}
			if (graph.containsKey(edge.getToNode()))
			{
				graph.get(edge.getToNode()).add(edge);
			} else
			{
				graph.put(edge.getToNode(), new HashSet<Edge>() {

					
					{
						add(edge);
					}
				});
			}
		}
	}