com.venky.network.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
Commonly used programming tasks in java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.venky.network;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
*
* @author venky
*/
public class Node {
public Node(){
}
private Map attributes;
public final void setAttribute(String name, V value){
attributes.put(name, value);
}
@SuppressWarnings("unchecked")
public final V getAttribute(String name){
return (V)attributes.get(name);
}
private Set edges = new HashSet();
public Set getEdges() {
return edges;
}
protected void addEdge(Edge e){
if (!e.getNodesConnected().contains(this.getId())){
throw new RuntimeException("Edge " + e.toString() + " does not connect with node." + id );
}
edges.add(e);
}
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}