Пример #1
0
        public void AromaticBenzene()
        {
            Graph g = new Graph(6);

            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddEdge(new Edge(0, 1, Bond.Implicit));
            g.AddEdge(new Edge(1, 2, Bond.Implicit));
            g.AddEdge(new Edge(2, 3, Bond.Implicit));
            g.AddEdge(new Edge(3, 4, Bond.Implicit));
            g.AddEdge(new Edge(4, 5, Bond.Implicit));
            g.AddEdge(new Edge(5, 0, Bond.Implicit));

            Graph h = new ImplicitToExplicit().Apply(g);

            Assert.AreNotSame(h, g);

            for (int u = 0; u < h.Order; u++)
            {
                foreach (var e in h.GetEdges(u))
                {
                    Assert.AreEqual(Bond.Aromatic, e.Bond);
                }
            }
        }
Пример #2
0
        public void KekuleBenzene()
        {
            Graph g = new Graph(6);

            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddEdge(new Edge(0, 1, Bond.Implicit));
            g.AddEdge(new Edge(1, 2, Bond.Double));
            g.AddEdge(new Edge(2, 3, Bond.Implicit));
            g.AddEdge(new Edge(3, 4, Bond.Double));
            g.AddEdge(new Edge(4, 5, Bond.Implicit));
            g.AddEdge(new Edge(5, 0, Bond.Double));

            Graph h = new ImplicitToExplicit().Apply(g);

            Assert.AreNotSame(h, g);

            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(0, 1, Bond.Single),
                new Edge(0, 5, Bond.Double)
            },
                              h.GetEdges(0)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(1, 0, Bond.Single),
                new Edge(1, 2, Bond.Double)
            },
                              h.GetEdges(1)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(2, 1, Bond.Double),
                new Edge(2, 3, Bond.Single)
            },
                              h.GetEdges(2)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(3, 2, Bond.Single),
                new Edge(3, 4, Bond.Double)
            },
                              h.GetEdges(3)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(4, 3, Bond.Double),
                new Edge(4, 5, Bond.Single)
            },
                              h.GetEdges(4)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(5, 0, Bond.Double),
                new Edge(5, 4, Bond.Single)
            },
                              h.GetEdges(5)));
        }