javaDSL简单实现示例分享
程序员文章站
2024-02-23 16:52:22
复制代码 代码如下:package com.vd.dsl;import static com.vd.dsl.graphbuilder.*;public class main...
复制代码 代码如下:
package com.vd.dsl;
import static com.vd.dsl.graphbuilder.*;
public class main {
public static void main(string[] args) {
graph().edge().from("a").to("b").weigth(20.0).edge().from("b").to("c").weigth(10.0).printgraph();
}
}
复制代码 代码如下:
package com.vd.dsl;
public class edge {
private vertex fromvertex;
private vertex tovertex;
public vertex getfromvertex() {
return fromvertex;
}
public void setfromvertex(vertex fromvertex) {
this.fromvertex = fromvertex;
}
public vertex gettovertex() {
return tovertex;
}
public void settovertex(vertex tovertex) {
this.tovertex = tovertex;
}
public double getweight() {
return weight;
}
public void setweight(double weight) {
this.weight = weight;
}
private double weight;
public edge() {
}
@override
public string tostring() {
return fromvertex.getlabel()+ " to "+
tovertex.getlabel() + "with weigth "+
this.weight;
}
}
上一篇: 关于线程池你不得不知道的一些设置
下一篇: 一名Java高级工程师需要学什么?