객체 인스턴스화 :
reason: actual argument org.apache.commons.collections15.Transformer<selfsimilarity.MyLink,java.lang.Double> cannot be converted to org.apache.commons.collections15.Transformer<selfsimilarity.MyLink,java.lang.Number> by method invocation conversion
: EdmondsKarp Object자바 정 나는 자바 정 그래프 패키지에서 다음과 같은 구성하기 위해 노력하고
EdmondsKarpMaxFlow<MyNode, MyLink> alg = new EdmondsKarpMaxFlow<MyNode, MyLink>(g, n2, n5, capTransformer, edgeFlowMap, flowEdgeFactory);
내가 오류가 왜 아무 생각이 여기 넷빈즈에서 오류 메시지입니다 .
본질적으로 나는 tutorial입니다.
EdmondsKarpMaxFlow 인스턴스 생성자는 생성자의 맨 아래에 있습니다. 생성자 다음에 EdmondsKarp 객체에 대한 모든 매개 변수에 대한 코드를 제공합니다. 이 매개 변수는 그래프, 원본 및 싱크 노드, 용량 변환기, 맵 및 가장자리 팩터 리입니다.
public GraphAlgTests()
{
g = new DirectedSparseMultigraph<MyNode, MyLink>();
// Create some MyNode objects to use as vertices
MyNode n1 = new MyNode(1); MyNode n2 = new MyNode(2); MyNode n3 = new MyNode(3);
MyNode n4 = new MyNode(4); MyNode n5 = new MyNode(5);
// Add some directed edges along with the vertices to the graph
g.addEdge(new MyLink(2.0, 48),n1, n2, EdgeType.DIRECTED); // This method
g.addEdge(new MyLink(2.0, 48),n2, n3, EdgeType.DIRECTED);
g.addEdge(new MyLink(3.0, 192), n3, n5, EdgeType.DIRECTED);
g.addEdge(new MyLink(2.0, 48), n5, n4, EdgeType.DIRECTED); // or we can use
g.addEdge(new MyLink(2.0, 48), n4, n2); // In a directed graph the
g.addEdge(new MyLink(2.0, 48), n3, n1); // first node is the source
g.addEdge(new MyLink(10.0, 48), n2, n5);// and the second the destination
EdmondsKarpMaxFlow<MyNode, MyLink> alg = new EdmondsKarpMaxFlow<MyNode, MyLink>(g, n2, n5, capTransformer, edgeFlowMap, flowEdgeFactory);
}
public class MyNode
{
private int id; // good coding practice would have this as private
public MyNode(int id)
{
this.id = id;
}
public String toString()
{ // Always a good idea for debuging
return "v"+id; // JUNG2 makes good use of these.
}
}
public class MyLink
{
double capacity; // should be private
double weight; // should be private for good practice
int id;
int edgeCount = 0;
public MyLink(double weight, double capacity)
{
this.id = edgeCount++;
this.weight = weight;
this.capacity = capacity;
}
public String toString()
{ // Always good for debugging
return "E"+id;
}
}
Transformer<MyLink, Double> capTransformer = new Transformer<MyLink, Double>()
//INFO: Gives the capacity of an edge, denoted here as a "link"
{
@Override
public Double transform(MyLink link)
{
return link.capacity;
}
};
Map<MyLink, Double> edgeFlowMap = new HashMap<MyLink, Double>();
Factory<MyLink> flowEdgeFactory = new Factory<MyLink>()
{
@Override
public MyLink create()
{
return new MyLink(1.0, 1.0);
}
};
기타 도움이 될만한 사항이 있으면 알려 주시기 바랍니다. 모든 도움에 감사드립니다! 그것은 정확하게 당신을 말하고