public class Edge {
private String id;
private double weight;
public Edge(String id, double weight){
this.id = id;
this.weight = weight;
}
public Edge(String id){
this.id = id;
this.weight = -1;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Edge other = (Edge) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
@Override
public String toString(){
return this.id;
}
}
And Vertex follows along the same lines. I try to implement ErdosRenyi or SmallWorldExample but I always get a null pointer. Should I create a custom Class for my network factory too? Doesn't it handle it directly? For example why can't I insert a Undirected Sparse Graph :/
Can you help me with an example of implementation?
Last edit: Petros Sideris 2013-11-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have custom classes for Edge and Vertex
And Vertex follows along the same lines. I try to implement ErdosRenyi or SmallWorldExample but I always get a null pointer. Should I create a custom Class for my network factory too? Doesn't it handle it directly? For example why can't I insert a Undirected Sparse Graph :/
Can you help me with an example of implementation?
Last edit: Petros Sideris 2013-11-29