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

📄 coloringalgorithm.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 ColoringAlgorithm {        public ArrayList<Integer> onecolorset;    public ArrayList<VexNode> thegraphcolorset;        public ColoringAlgorithm (ArrayList<VexNode> thegraph){        //默认构造函数        thegraphcolorset   =  thegraph;	}            public void DrawColor(){        //使用贪婪算法对交通图着色		       onecolorset    =   new ArrayList<Integer>();       VexNode tnode;       int count;       boolean flag;        int  si=  thegraphcolorset.size();       int color = 0;       for(count=0;count<si;){           onecolorset.clear();           color++;           for(int i=0;i<si;i++){               tnode=thegraphcolorset.get(i);               if(tnode.vexcolor==0){                   flag=true;                    ArrayList<Integer> first = tnode.firstarc ;                   int fsize = first.size();                   for(int j=0;j<fsize;j++)                       if(onecolorset.contains(first.get(j))){                           flag=false;                           break;                       }                   if(flag){                       tnode.vexcolor = color;                       onecolorset.add(tnode.vexnum);                       count++;                   }               }                              }       }    }}

⌨️ 快捷键说明

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