I am new to C# and am trying to understand if there is a very simple way to rewrite this code.
List<Vertex<string>> vertices = new List<Vertex<string>>
(
new Vertex<string>[]
{
new Vertex<string>("Los Angeles"),
new Vertex<string>("San Francisco"),
new Vertex<string>("Las Vegas"),
new Vertex<string>("Seattle"),
new Vertex<string>("Austin"),
new Vertex<string>("Portland")
}
);
// Establish edges; Ex. Los Angeles -> San Francisco, Las Vegas, Portland
vertices[0].AddEdges(new List<Vertex<string>>(new Vertex<string>[]
{
vertices[1], vertices[2], vertices[5]
}));
some thing like the below to make it easy to understand
List<Vertex<string>> vertices = new List<Vertex<string>>();
var vrtx = new Vertex<string>[]
{
new Vertex<string>("Los Angeles"),
new Vertex<string>("San Francisco"),
new Vertex<string>("Las Vegas"),
new Vertex<string>("Seattle"),
new Vertex<string>("Austin"),
new Vertex<string>("Portland")
};