Exemple #1
0
        /// <summary>
        /// Calculates the rank for the graph specified by the provided scope.
        /// For ranks normalized between 0 and 1, use the CalculateNormalizedRank
        /// method.
        /// </summary>
        /// <param name="scope">The scope for the graph to be ranked</param>
        /// <returns>the ranking for the nodes on the graph in the form
        /// of a dictionary of nodes and their scores.  The ranking is
        /// normalized between 0 and 1.</returns>
        public override Dictionary <INode, double> CalculateRank(string scope)
        {
            // Valid the scope parameter
            if (string.IsNullOrEmpty(scope))
            {
                throw new ArgumentNullException("Scope", "No scope was provided");
            }

            // Initialize the results dictionary
            Dictionary <INode, double> results = new Dictionary <INode, double>();

            // Get the graph data using the provided scope
            GraphData graph = GraphManager.Instance.GetGraphComponents(scope).Data;

            // Loop over all the nodes in the graph
            foreach (INode node in graph.Nodes)
            {
                // Get the degree for the current node
                results[node] = graph.Degree(node);
            }

            return(results);
        }
Exemple #2
0
 /// <summary>
 /// Returns the number of edges for the provided Node
 /// </summary>
 /// <param name="node">The Node to count the edges for</param>
 /// <returns>the number of edges for the Node</returns>
 public int GetNumberOfEdges(INode node)
 {
     return(graphData.Degree(node));
 }