Java 有向图的指数和出度的计算

Java 有向图的指数和出度的计算,java,digraphs,Java,Digraphs,首先也是最重要的一点,我使用的是移动设备,因此这可能看起来不太好看,因为典型的编辑选项不可用。我有点搞不清楚如何进行查找索引和超出度。这是Coursera提供的。我知道,在度中是边进来,在度中是边出去 import java.util.*; import java.io.*; class UnweightedGraph<V> { //A HashMap of lists for Adjacency list representation. Key is a sou

首先也是最重要的一点,我使用的是移动设备,因此这可能看起来不太好看,因为典型的编辑选项不可用。我有点搞不清楚如何进行查找索引和超出度。这是Coursera提供的。我知道,在度中是边进来,在度中是边出去

 import java.util.*;
 import java.io.*;

 class UnweightedGraph<V>
    {
//A HashMap of lists for Adjacency list representation. Key is a   source vertex and 
//value is a list of outgoing edges (i.e., destination vertices) for the key
private HashMap<V,LinkedList<V>> adj;

public UnweightedGraph()
{
    adj = new HashMap<V,LinkedList<V>>();
}

/**
 * A function to add an edge
 * @param source : The source of the edge
 * @param dest: The destination of the edge
 */

public void addEdge(V source, V dest)
{
    LinkedList<V> edgeList = adj.get(source);
    if (edgeList==null)
        edgeList = new LinkedList<V>();

    edgeList.add(dest);
    adj.put(source, edgeList);
}







 /**
 * Computes the in-degree and outDegree for each vertex in the graph
 * @returns a dictionary which maps every vertex to its Degree object containing the in-degree and out-degreeo of the vertex
 */
  public Map<V, Degree> findInOutDegrees()
   {
// TO DO : YOUR IMPLEMENTATION GOES HERE
//Map <V, Degree > computeInOutDegree = new HashMap<V,    Degree>();
adj.
for (V vertice : adj.get(V)) {
    vertice.
}


 }



  }

我的问题是,到目前为止,我在计算inoutdegrees的方法上到底做错了什么。这真让我难以置信

你忘了添加问题。你忘了添加问题。
   public class Degree {


//Number off incoming edges to a vertex
int indegree;

//number of outgoing edges from a vertex
int outdegree;

//Constructor
public Degree ( int indegree, int outdegree){

    this.indegree= indegree;
    this.outdegree= outdegree;
}


//Getter and Setter MNethods

public int getIndegree() {
    return indegree;
}

public void setIndegree(int indegree) {
    this.indegree = indegree;
}

public int getOutdegree() {
    return outdegree;
}

public void setOutdegree(int outdegree) {
    this.outdegree = outdegree;
}


   }