using System;
namespace ConsoleApp1
{
class Program
{
public class BanLie
{
public string[] name;
public int bnum;
public int[] maxqual;
public string[] start;
public class ALgraph
{
public class EdgeNode
{
public int adjvex;
public int weight;
public int length;
public int time;
public string[] type;
public float[] price;
public EdgeNode next;
public EdgeNode(int adjvex)
{
this.adjvex = adjvex;
}
}
public class VertexNode
{
public string vertex;
public EdgeNode first;
public VertexNode(string vertex)
{
this.vertex = vertex;
this.first = null;
}
}
public class GraphAdjlist
{
public VertexNode[] vertexNode;
public int vexnum, arcnum;
public GraphAdjlist(int vexnum, int arcnum,string vertexs)
{
this.vexnum = vexnum;
this.arcnum = arcnum;
string[] vertex = vertexs.Split(',');
vertexNode = new VertexNode[vexnum];
for (int i = 0; i < vexnum; i++)
{
vertexNode[i] = new VertexNode(vertex[i]);
}
}
}
public GraphAdjlist graphAdjlist = new GraphAdjlist(4, 5,"a,b,c,d") { };
public void InitEdges(int fromVertexNode, int toVertexNode)
{
EdgeNode temp = new EdgeNode(fromVertexNode) { next = graphAdjlist.vertexNode[toVertexNode].first };
graphAdjlist.vertexNode[toVertexNode].first = temp;
temp = new EdgeNode(toVertexNode) { next = graphAdjlist.vertexNode[fromVertexNode].first };
graphAdjlist.vertexNode[fromVertexNode].first = temp;
}
public void CreatALgraph()
{
InitEdges(0, 1);
InitEdges(0, 2);
InitEdges(0, 3);
InitEdges(2, 1);
InitEdges(2, 3);
}
public void ShowALgraph()
{
for (int i = 0; i < graphAdjlist.vexnum; i++)
{
Console.WriteLine("顶点" + i + "为:" + graphAdjlist.vertexNode[i].vertex + "--first--");
EdgeNode temp = new EdgeNode(0);
temp = graphAdjlist.vertexNode[i].first;
Console.WriteLine(temp.adjvex + "--next--");
while (temp != null)
{
Console.WriteLine(temp.adjvex + "--next--");
temp = temp.next;
}
Console.WriteLine("END-" + graphAdjlist.vertexNode[i].vertex);
}
}
}
}
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
BanLie.ALgraph CreatALgraph = new BanLie.ALgraph();
CreatALgraph.CreatALgraph();
BanLie.ALgraph ShowALgraph = new BanLie.ALgraph();
ShowALgraph.ShowALgraph();
}
public class com
{
public string[] cname;
public float[] cqual;
public string[] ctype;
public string[] formcountry;
public string[] tocountry;
public float[] price;
}
}
}