예제 #1
0
            // returns a list of statements because we may need to declare node attribute statments
            // or other things to describe the WME
            public IEnumerable <Statement> GetStatement()
            {
                List <Statement> statements = new List <Statement>();

                if (IsIdentifier())
                {
                    // add an edge statement
                    EdgeStatement statement = EdgeStatement.EdgeBetweenNodes(ID, value);
                    statement.attributes.Add(new StringAttribute("label", attribute.Replace("-", "_")));
                    statements.Add(statement);
                }
                else
                {
                    // get a new id for the value
                    string newID = getNewID();
                    // make edge statement
                    EdgeStatement statement = EdgeStatement.EdgeBetweenNodes(ID, newID);
                    statement.attributes.Add(new StringAttribute("label", attribute.Replace("-", "_")));
                    statements.Add(statement);
                    // add a node attribute statement to label the child
                    NodeStatement nodeStatement = new NodeStatement(newID);
                    nodeStatement.attributes.Add(new StringAttribute("label", value.Replace("-", "_")));
                    statements.Add(nodeStatement);
                }
                return(statements);
            }
예제 #2
0
        public static void Test1()
        {
            Graph graph = new Graph(Graph.EGraphType.GT_Digraph, "hellograph");

            // add edge

            /*EdgeStatement edgeStatement = new EdgeStatement();
             * edgeStatement.nodeID = new NodeStatement.NodeID("A");
             * edgeStatement.rhs = new EdgeStatement.EdgeRHS();
             * edgeStatement.rhs.nodeID = new NodeStatement.NodeID("B");
             * graph.statements.Add(edgeStatement);*/
            graph.statements.Add(EdgeStatement.EdgeBetweenNodes("A", "B"));

            string result = graph.Render();

            // display result
            Console.Write(result);

            System.IO.StreamWriter writer = new System.IO.StreamWriter("graph.txt");
            writer.Write(result);
            writer.Close();

            Console.ReadKey();
        }