public string GetProperties(INetwork network)
 {
     var sb = new StringBuilder();
     if (network == null)
     {
         sb.AppendLine("network is null");
     }
     else
     {
         ListPropertiesOfNetworkBase(network, sb);
         if (network is IAdjList)
         {
             ListPropertiesOfAdjList((IAdjList)network, sb);
         }
         else
         {
             var isMatrix = network.GetType().GetInterfaces()
                                   .Where(t => t.IsGenericType)
                                   .Select(t => t.GetGenericTypeDefinition())
                                   .Any(t => t.Equals(typeof(IMatrix<>)));
             if (isMatrix)
                 ListPropertiesOfMatrix(network, sb);
         }
     }
     return sb.ToString();
 }
Пример #2
0
        internal int ExtractKthCore(INetwork network, int kValue)
        {
            int removed = 0;
            if (network is IBasicAdjList)
                removed = ExtractKthCoreFromAdjList(network as IBasicAdjList, kValue);
            else
            {
                var isMatrix = network.GetType().GetInterfaces()
                    .Where(t => t.IsGenericType)
                    .Select(t => t.GetGenericTypeDefinition())
                    .Any(t => t.Equals(typeof(IMatrix<>)));

                if (isMatrix)
                removed = ExtractKthCoreFromMatrix(network, kValue);
            }

            return removed;
        }
 public void ListPropertiesOfNetworkBase(INetwork network, StringBuilder sb)
 {
     sb.AppendLine(string.Format("Id:  {0}", network.Id));
     sb.AppendLine(string.Format("Name:  \"{0}\"", network.Name));
     sb.AppendLine(string.Format("Node count:  {0}", network.NodeCount));
     sb.AppendLine(string.Format("Edge count:  {0}", network.EdgeCount));
     sb.AppendLine(string.Format("Directed:  {0}", network.IsDirected));
     sb.AppendLine(string.Format("Structure:  {0}", network.Structure));
     sb.AppendLine(string.Format("Implementation:  {0}", network.GetType().Name));
 }