package com.example.data_structure.service; import com.example.data_structure.domain.UDUWGraph; import com.example.data_structure.domain.UDWGraph; import com.example.data_structure.vo.GraphTraversalStep; import com.example.data_structure.vo.GraphTraversalVO; import com.example.data_structure.vo.PrimMinimumSpanningTree; import org.springframework.stereotype.Service; import java.util.*; @Service public class GraphService { private static final int NODE_NUM=7; //获取一个新的无向非带权图 public UDUWGraph getNewUDUDGraph(){ ArrayList> content=new ArrayList>(); for(int i=0;i raw=new ArrayList(); for(int j=0;j> content=new ArrayList>(); for(int i=0;i raw=new ArrayList(); for(int j=0;j> content=graph.getContent(); ArrayList visitSequence =new ArrayList(); ArrayList visited=new ArrayList(); ArrayList visitStartNode=new ArrayList(); for(int i=0;i steps=new ArrayList(); for(int i=0;i q=new LinkedList(); q.add(startVertex); while(!q.isEmpty()){ int curVertex=q.poll(); steps.add(new GraphTraversalStep("visit",visitStartNode.get(curVertex),curVertex,true)); visited.set(curVertex,1); visitSequence.add(curVertex); for(int i=0;i> content=new ArrayList>(); GraphTraversalVO graphTraversalVO =new GraphTraversalVO(); graphTraversalVO.setGraph(graph); ArrayList steps=new ArrayList(); GraphTraversalStep currentStep=new GraphTraversalStep(); ArrayList visitSequence=new ArrayList(); ArrayList visited=new ArrayList(); ArrayList visitStartNode=new ArrayList(); for(int i=0;i stack=new Stack(); stack.push(startVertex); while(!stack.isEmpty()){ boolean isTerminal=false; } return null; } //获取无向带权图的prim算法的最小生成树 public PrimMinimumSpanningTree getPrimMinimumSpanningTree(UDUWGraph graph,int startVertex){ return null; } }