title: Calculating outdegree of a node in Graph
body: <p>I have implemented following code for Graph. For calculating the outdegree of any node outDegree funcion is there. It will take the name of the node, whose outDegree need to be calculated. I was wondering that in calculating the outDegree of any node, can I use find() function provided in vector. If yes, how ?     </p>
  
  <pre><code>    #include&lt;iostream&gt;
      #include&lt;iterator&gt;
      #include&lt;vector&gt;
      #include&lt;list&gt;
      using namespace std;
      template&lt;class T1,class T2&gt;
      class Edge{
              public:
              T1 d_vertex;
              T2 d_weight;
              Edge(T1,T2);
              T1 vertex();
              T2 weight();
      };
      template&lt;class T1,class T2&gt;
      Edge&lt;T1,T2&gt;::Edge(T1 v,T2 w):d_vertex(v),d_weight(w){
      }
      template&lt;class T1,class T2&gt;
      T1 Edge&lt;T1,T2&gt;:: vertex(){
              return d_vertex;
      }
      template&lt;class T1,class T2&gt;
      T2 Edge&lt;T1,T2&gt;::weight(){
              return d_weight;
      }
      template&lt;class T,class T2&gt;
      class Graph{
              vector&lt;pair&lt;T, list&lt;T2&gt; &gt; &gt; node;
              public:
              void addNode(T data,const list&lt;T2&gt;&amp;);
              void show();
              int outDegree(T);
      };
     ////////////////////////////////////////////////////////////////////
      template&lt;class T,class T2&gt;
      int Graph&lt;T,T2&gt;::outDegree(T node_name){
              for(int i=0;i&lt;node.size();i++){
                      if(node[i].first==node_name)
                              break;
    }
          if(i==node.size())
                  return -1;
          else
          return(node[i].second.size());
  }
  template&lt;class T,class T2&gt;
  void Graph&lt;T,T2&gt;:: addNode(T data, const list&lt;T2&gt;&amp; lst){
          node.push_back(pair&lt;T, list&lt;T2&gt; &gt;(data,lst));
  }
  template&lt;class T,class T2&gt;
  void Graph&lt;T,T2&gt;:: show(){
          for(int i=0;i&lt;node.size();i++){
                  cout&lt;&lt;node[i].first&lt;&lt;"------ ";
                  for(typename list&lt;T2&gt; :: iterator it=node[i].second.begin();it!=node[i].second.end();it++)
                          cout&lt;&lt;(*it).d_vertex&lt;&lt;" ";
                  cout&lt;&lt;endl;
          }
  }
  int main(){
          Graph&lt;int,Edge&lt;int,float&gt; &gt; g;
          list&lt;Edge&lt;int,float&gt; &gt; x;
          x.push_back(Edge&lt;int,float&gt;(4,float(3.5)));
          x.push_back(Edge&lt;int,float&gt;(5,float(4.0)));
          g.addNode(3,x);
          list&lt;Edge&lt;int,float&gt; &gt; y;
          y.push_back(Edge&lt;int,float&gt;(4,float(6.3)));
          y.push_back(Edge&lt;int,float&gt;(2,float(12.0)));
          y.push_back(Edge&lt;int,float&gt;(1,float(2.1)));
          g.addNode(6,y);
          g.show();
          cout&lt;&lt;g.outDegree(6);
  }
  </code></pre>