⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fivejunction.java

📁 主要功能:对五条道路的车辆进行控制
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package fivestarcross;import java.util.ArrayList;/** * * @author Dante */public class FiveJunction {        public float [][] traffic;    public ArrayList<VexNode> traffic_graph=new ArrayList<VexNode>(20);//创建交通图            public FiveJunction(float [][] traffic){        this.traffic =traffic;        newNodeList();    }        public void newNodeList(){        int index;        for(int i=0;i<=4;i++)            for(int j=0;j<=4;j++){                if(i!=j){                    char[] ch={(char) ('A' + i),(char) ('A' + j)};                    String   str   =   new   String(ch);                    VexNode node =new VexNode(i*5+j,str,traffic[i][j]);                    node.firstarc = requestConflict(i,j);                    int si=traffic_graph.size();                    for(index=0;index<si;index++){                        if(traffic_graph.get(index).vextraffic<traffic[i][j])                            break;                    }                                            traffic_graph.add(index,node);                }            }        new ColoringAlgorithm(traffic_graph).DrawColor();    }        public ArrayList<Integer> requestConflict(int A,int B){           ArrayList<Integer> firstarc = new ArrayList<Integer>();//指向第一条边                for(int i=0;i<=4;i++)            for(int j=0;j<=4;j++){                if(A<B){                    if(i>A&&i<=B&&(j>B||j<A)||(i>B||i<A)&&j>=A&&j<B){                        firstarc.add(i*5+j);                    }                }                else{                    if((i>A||i<=B)&&(j>B&&j<A)||(i>B&&i<A)&&(j>=A||j<B)){                    firstarc.add(i*5+j);                    }                }            }        return firstarc;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -