예제 #1
0
 public static string ToJson(SparseIntVect64 vector)
 {
     var sb = new StringBuilder();
     sb.Append("{");
     sb.Append($"\"size\":{vector.Count()},");
     sb.Append("\"nonzero\":{");
     sb.Append(string.Join(",", vector.GetNonzero().Select(n => $"{n.first}:{n.second}")));
     sb.Append("}}");
     return sb.ToString();
 }
예제 #2
0
 public static RDKitSparseVector FromSIV(SparseIntVect64 vector)
 {
     var o = new RDKitSparseVector()
     {
         Size = vector.Count(),
     };
     o.Nonzero = new Dictionary<long, int>();
     foreach (var e in vector.getNonzero())
     {
         o.Nonzero.Add(e.first, e.second);
     }
     return o;
 }