亲宝软件园·资讯

展开

javaDSL实现 javaDSL简单实现示例分享

人气:0
想了解javaDSL简单实现示例讲解的相关内容吗,在本文为您仔细讲解javaDSL实现的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:javaDSL,下面大家一起来学习吧。

复制代码 代码如下:

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;
 }
}

加载全部内容

相关教程
猜你喜欢
用户评论