Пример #1
0
 public bool Contains(ElementType faceType)
 {
     if (faceType == Type)
     {
         return(true);
     }
     else
     {
         if (_collection != null)
         {
             return(_collection.Contains(faceType));
         }
     }
     return(false);
 }
Пример #2
0
        TestLoadGraph2()
        {
            // Undirected file.

            const String FileContents =
                "DL\r\n"
                + "N=4\r\n"
                + "FORMAT = FULLMATRIX DIAGONAL PRESENT\r\n"
                + "ROW LABELS:\r\n"
                + "\"a\"\r\n"
                + "\"b\"\r\n"
                + "\"c\"\r\n"
                + "\"d\"\r\n"
                + "COLUMN LABELS:\r\n"
                + "\"a\"\r\n"
                + "\"b\"\r\n"
                + "\"c\"\r\n"
                + "\"d\"\r\n"
                + "DATA:\r\n"
                + "0 0 0 0\r\n"
                + "0 0 3 1\r\n"
                + "0 3 4.12 0\r\n"
                + "0 1 0 0\r\n"
            ;

            using (StreamWriter oStreamWriter = new StreamWriter(m_sTempFileName))
            {
                oStreamWriter.Write(FileContents);
            }

            IGraph oGraph = m_oGraphAdapter.LoadGraph(m_sTempFileName,
                                                      GraphDirectedness.Undirected);

            Assert.IsInstanceOfType(oGraph, typeof(Graph));

            IVertexCollection oVertices = oGraph.Vertices;

            Assert.AreEqual(4, oVertices.Count);

            Assert.IsTrue(oVertices.Contains("a"));
            Assert.IsTrue(oVertices.Contains("b"));
            Assert.IsTrue(oVertices.Contains("c"));
            Assert.IsTrue(oVertices.Contains("d"));

            IEdgeCollection oEdges = oGraph.Edges;

            Assert.AreEqual(3, oEdges.Count);

            // The key is a concatenation of vertex names and the value is the
            // edge.

            Dictionary <String, IEdge> oEdgeDictionary =
                new Dictionary <String, IEdge>(3);

            foreach (IEdge oEdge in oEdges)
            {
                String sName0 = oEdge.Vertices[0].Name;
                String sName1 = oEdge.Vertices[1].Name;

                oEdgeDictionary.Add(

                    sName0.CompareTo(sName1) > 0 ?
                    (sName1 + sName0) : (sName0 + sName1),

                    oEdge);
            }

            Assert.AreEqual(3, oEdgeDictionary.Count);

            IEdge oFoundEdge;

            Assert.IsTrue(oEdgeDictionary.TryGetValue("bd", out oFoundEdge));

            Assert.AreEqual(1.0, oFoundEdge.GetRequiredValue(
                                ReservedMetadataKeys.EdgeWeight, typeof(Double)));

            Assert.IsTrue(oEdgeDictionary.TryGetValue("bc", out oFoundEdge));

            Assert.AreEqual(3.0, oFoundEdge.GetRequiredValue(
                                ReservedMetadataKeys.EdgeWeight, typeof(Double)));

            Assert.IsTrue(oEdgeDictionary.TryGetValue("cc", out oFoundEdge));

            Assert.AreEqual(4.12, oFoundEdge.GetRequiredValue(
                                ReservedMetadataKeys.EdgeWeight, typeof(Double)));
        }
Пример #3
0
 public bool Contains(ElementType faceType)
 {
     return(collection.Contains(faceType));
 }