算法<七>深度优先搜索算法

package com.example.demo.SortAlgorithm;
/*
 * @Author: i_heh
 * @Date: 2019/7/5
 * @Time: 14:16
 * @Description:
 */
public class DFS {
    private int[][] adjMat;
    //private int size;
    private Vertex[] vertexArr;
    private int num;
    private StackGraph sg;
    public static void main(String[] args) {
        DFS g = new DFS(5);
        g.addVertex('A');
        g.addVertex('B');
        g.addVertex('C');
        g.addVertex('D');
        g.addVertex('E');
        g.addVertex('F');
        g.addEdge(0, 1);
        g.addEdge(0, 2);
        g.addEdge(1, 3);
        g.addEdge(2, 3);
        g.addEdge(0, 4);
        g.showGraph();
        System.out.print("visits:");
        g.dfs();
        //System.out.println();
    }
    public DFS(int s){
        //size = s;
        num = 0;
        adjMat = new int[s][s];
        vertexArr = new Vertex[s];
        for(int i=0;i

你可能感兴趣的:(算法<七>深度优先搜索算法)