本文整理汇总了C#中Graph类的典型用法代码示例。如果您正苦于以下问题:C# Graph类的具体用法?C# Graph怎么用?C# Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Graph类属于命名空间,在下文中一共展示了Graph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: NodesDistinct
public void NodesDistinct()
{
Graph g = new Graph();
List<INode> test = new List<INode>()
{
g.CreateUriNode("rdf:type"),
g.CreateUriNode(new Uri("http://example.org")),
g.CreateBlankNode(),
g.CreateBlankNode(),
null,
g.CreateBlankNode("test"),
g.CreateLiteralNode("Test text"),
g.CreateLiteralNode("Test text", "en"),
g.CreateLiteralNode("Test text", new Uri(XmlSpecsHelper.XmlSchemaDataTypeString)),
g.CreateUriNode("rdf:type"),
null,
g.CreateUriNode(new Uri("http://example.org#test")),
g.CreateUriNode(new Uri("http://example.org"))
};
foreach (INode n in test.Distinct())
{
if (n != null)
{
Console.WriteLine(n.ToString());
}
else
{
Console.WriteLine("null");
}
}
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:32,代码来源:BasicTests1.cs
示例2: FormSprite
int widthForm, heightForm; // размеры основной формы
#endregion Fields
#region Constructors
public FormSprite()
{
InitializeComponent();
widthForm = this.Size.Width;
heightForm = this.Size.Height;
stepNet = 10;
stepShift = 1;
toolStripLabelXW.Text = "xW=" + this.Size.Width;
toolStripLabelYW.Text = "yW=" + this.Size.Height;
toolStripComboBoxWidthPen.SelectedIndex = 2;
toolStripComboBoxStepNet.SelectedIndex = 0;
toolStripComboBoxShift.SelectedIndex = 0;
graph = new Graph(picture.Width, picture.Height);
sprite = new Sprite();
currPens = new DataSprite.Pens(ColorTranslator.ToHtml(Color.Black), 3);
currFigure = new MyLine(currPens, 1, 1, 1, 1);
flagLine = false;
picture.Image = graph.GetBitmap;
}
开发者ID:Rammun,项目名称:SpriteEditor,代码行数:31,代码来源:FormSprite.cs
示例3: BuildLevel
public void BuildLevel(Board board)
{
var children = new List<GameObject>();
foreach (Transform child in transform)
children.Add(child.gameObject);
children.ForEach(child => Destroy(child));
originalMatrix = board.Grid;
matrix = PrepareMatrix(originalMatrix);
int n = board.NoRooms;
floors = new Floor[matrix.GetLength(0)-2,matrix.GetLength(1)-2];
walls = new Wall[matrix.GetLength(0)-1, matrix.GetLength(1)-1];
Rooms = new Room[n];
graph = new Graph();
for (int i = 0; i < n; ++i)
{
Rooms[i] = new Room(i+1, DefaultFloorMaterial);
}
RoomPropertiesPanel.InitializePanel(n);
Vector3 shift = new Vector3(((matrix.GetLength(1) - 2) * unit) / 2, 0f, ((matrix.GetLength(0) - 2) * -unit) / 2);
this.transform.position = shift;
SpawnWalls();
SpawnFloors();
SpawnDoors();
foreach (var room in Rooms)
{
room.SetRoomMaterial();
}
isSaved = false;
}
开发者ID:DormantDreams,项目名称:video-game-level-scanner,代码行数:30,代码来源:LevelBuilder.cs
示例4: SymbolGraph
public SymbolGraph(string[] graphData, char sp)
{
st = new BST<string, string>();
for (int i = 0; i < graphData.Length; i++)
{
string[] a = graphData[i].Split(sp);
foreach (string s in a)
{
if (!st.Contains(s))
{
st.Put(s, st.Size().ToString());
}
}
}
keys = new string[st.Size()];
foreach (string key in st.Keys())
{
keys[int.Parse(st.Get(key))] = key;
}
graph = new Graph(st.Size());
foreach (string data in graphData)
{
string[] a = data.Split(sp);
int v = int.Parse(st.Get(a[0]));
for (int i = 1; i < a.Length; i++)
{
graph.AddEdge(v, int.Parse(st.Get(a[i])));
}
}
}
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:35,代码来源:public+class+SymbolGraph.cs
示例5: StorageSesameSaveLoad
public void StorageSesameSaveLoad()
{
try
{
Graph g = new Graph();
FileLoader.Load(g, "InferenceTest.ttl");
g.BaseUri = new Uri("http://example.org/SesameTest");
SesameHttpProtocolConnector sesame = new SesameHttpProtocolConnector("http://nottm-virtual.ecs.soton.ac.uk:8080/openrdf-sesame/", "unit-test");
sesame.SaveGraph(g);
//Options.HttpDebugging = true;
//Options.HttpFullDebugging = true;
Graph h = new Graph();
sesame.LoadGraph(h, "http://example.org/SesameTest");
Assert.IsFalse(h.IsEmpty, "Graph should not be empty after loading");
Assert.AreEqual(g, h, "Graphs should have been equal");
}
catch (Exception ex)
{
TestTools.ReportError("Error", ex, true);
}
finally
{
//Options.HttpFullDebugging = false;
//Options.HttpDebugging = true;
}
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:30,代码来源:SesameTests.cs
示例6: VoIDDescription
/// <summary>
/// Creates a new VoID Description which is loaded from the given URI
/// </summary>
/// <param name="u">URI</param>
public VoIDDescription(Uri u)
{
Graph g = new Graph();
UriLoader.Load(g, u);
this.Initialise(g);
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:11,代码来源:VoIDDescription.cs
示例7: LoadData
private void LoadData()
{
var rows = File.ReadAllLines(DataFile);
graphDepth = rows.Length;
graph = new Graph(0) {PathLength = int.Parse(rows[0])};
var lastGraphs = new Graph[1];
lastGraphs[0] = graph;
for (var i = 1; i < rows.Length; i++)
{
var values = rows[i].Split(' ').Select(int.Parse).ToArray();
var graphs = new Graph[values.Length];
for (var j = 0; j < values.Length; j++)
{
graphs[j] = new Graph(i);
if (j != values.Length - 1)
{
lastGraphs[j].connectionList.Add(graphs[j], values[j]);
}
if (j != 0)
{
lastGraphs[j-1].connectionList.Add(graphs[j], values[j]);
}
}
lastGraphs = graphs;
}
}
开发者ID:Didovgopoly,项目名称:ProjectEuler,代码行数:28,代码来源:Problem18.cs
示例8: CheckCompressionRoundTrip
private void CheckCompressionRoundTrip(IGraph g)
{
foreach (KeyValuePair<IRdfWriter, IRdfReader> kvp in this._compressers)
{
IRdfWriter writer = kvp.Key;
if (writer is ICompressingWriter)
{
((ICompressingWriter)writer).CompressionLevel = WriterCompressionLevel.High;
}
if (writer is IHighSpeedWriter)
{
((IHighSpeedWriter)writer).HighSpeedModePermitted = false;
}
System.IO.StringWriter strWriter = new System.IO.StringWriter();
writer.Save(g, strWriter);
Console.WriteLine("Compressed Output using " + kvp.Key.GetType().Name);
Console.WriteLine(strWriter.ToString());
Console.WriteLine();
Graph h = new Graph();
StringParser.Parse(h, strWriter.ToString(), kvp.Value);
Assert.AreEqual(g, h, "Graphs should be equal after round trip to and from serialization using " + kvp.Key.GetType().Name);
}
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:CollectionCompressionTests.cs
示例9: hasAdjacentNodeTest
public void hasAdjacentNodeTest()
{
try
{
Graph g = new Graph();
Node n1 = new PointOfInterest(1, 0, 0, 1);
Node n2 = new PointOfInterest(2, 0, 0, 1);
Node n3 = new PointOfInterest(3, 0, 0, 1);
g.InsertNewVertex(n1);
g.InsertNewVertex(n2);
g.InsertNewVertex(n3);
n1.addListOfAdjacentNodes(new Dictionary<Node, float>() { { n2, 4 } });
n2.addListOfAdjacentNodes(new Dictionary<Node, float>() { { n1, 3 } });
Assert.IsNotNull(g);
Assert.IsNotNull(n1);
Assert.IsNotNull(n2);
Assert.IsNotNull(n3);
Assert.True(n1.isAdjacent(n2),
"This tests if isAdjacent returns true if a node is adjacent to a given one.");
}
catch (SecurityException e)
{
Console.WriteLine("Security Exception:\n\n{0}", e.Message);
}
}
开发者ID:joseph93,项目名称:Genos,代码行数:28,代码来源:NodeTests.cs
示例10: Main
public static void Main()
{
var graph = new Graph(new[]
{
new List<int> {3, 6}, // children of node 0 (Ruse)
new List<int> {2, 3, 4, 5, 6}, // children of node 1 (Sofia)
new List<int> {1, 4, 5}, // children of node 2 (Pleven)
new List<int> {0, 1, 5}, // children of node 3 (Varna)
new List<int> {1, 2, 6}, // children of node 4 (Bourgas)
new List<int> {1, 2, 3}, // children of node 5 (Stara Zagora)
new List<int> {0, 1, 4} // children of node 6 (Plovdiv)
},
new string[] { "Ruse", "Sofia", "Pleven", "Varna", "Bourgas", "Stara Zagora", "Plovdiv" }
);
// Print the nodes and their children
for (int nodeIndex = 0; nodeIndex < graph.ChildNodes.Length; nodeIndex++)
{
Console.WriteLine("{0} -> {1}", nodeIndex,
string.Join(" ", graph.ChildNodes[nodeIndex]));
}
Console.WriteLine();
// Print the node names and their children names
for (int nodeIndex = 0; nodeIndex < graph.ChildNodes.Length; nodeIndex++)
{
Console.WriteLine("{0} -> {1}",
graph.NodeNames[nodeIndex],
string.Join(", ", graph.ChildNodes[nodeIndex]
.Select(node => graph.NodeNames[node])));
}
}
开发者ID:vangelov-i,项目名称:Fundamentals,代码行数:33,代码来源:AdjacencyListGraph.cs
示例11: Simple
public void Simple()
{
var graph = new Graph<int>(false);
var vertices = new Vertex<int>[20];
for (var i = 0; i < 20; i++)
{
vertices[i] = new Vertex<int>(i);
graph.AddVertex(vertices[i]);
}
for (var i = 0; i < 17; i += 2)
{
var edge = new Edge<int>(vertices[i], vertices[i + 2], false);
graph.AddEdge(edge);
}
var trackingVisitor = new TrackingVisitor<int>();
graph.AcceptVisitor(trackingVisitor);
Assert.AreEqual(trackingVisitor.TrackingList.Count, 20);
for (var i = 0; i < 20; i++)
{
Assert.IsTrue(trackingVisitor.TrackingList.Contains(i));
}
}
开发者ID:havok,项目名称:ngenerics,代码行数:29,代码来源:Accept.cs
示例12: GenerateDiagram
internal override IList<Node> GenerateDiagram(Graph graph, Node parentNode)
{
var result = base.GenerateDiagram(graph, parentNode);
var node = result[0];
node.EscalationLevel = EscalationLevel;
if (Escalations != null )
{
foreach (var escalation in Escalations)
{
var nodes = escalation.GenerateDiagram(graph, node);
foreach (var childNode in nodes)
{
var link = graph.Links.FirstOrDefault(l => l.From == node && l.To == childNode);
if (link != null)
{
link.Text = $"Escalation Level {Escalations.IndexOf(escalation) + 1}";
link.Category = "Escalation";
}
}
}
}
return result;
}
开发者ID:mparsin,项目名称:TBMS,代码行数:26,代码来源:AsyncTask.cs
示例13: PotentialMethod
public PotentialMethod(Graph<int> orientedGraph, List<int> production)
{
S = orientedGraph;
Production = production;
IsFirstPhaseNeeded = true;
}
开发者ID:Kant8,项目名称:IOp,代码行数:7,代码来源:PotentialMethod.cs
示例14: SparqlFunctionsIsNumeric
public void SparqlFunctionsIsNumeric()
{
Graph g = new Graph();
IUriNode subj = g.CreateUriNode(new Uri("http://example.org/subject"));
IUriNode pred = g.CreateUriNode(new Uri("http://example.org/predicate"));
g.Assert(subj, pred, (12).ToLiteral(g));
g.Assert(subj, pred, g.CreateLiteralNode("12"));
g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonNegativeInteger)));
g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonPositiveInteger)));
g.Assert(subj, pred, g.CreateLiteralNode("1200", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
g.Assert(subj, pred, ((byte)50).ToLiteral(g));
g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeUnsignedByte)));
g.Assert(subj, pred, g.CreateUriNode(new Uri("http://example.org")));
TripleStore store = new TripleStore();
store.Add(g);
SparqlQueryParser parser = new SparqlQueryParser();
SparqlQuery q = parser.ParseFromString("SELECT ?obj (IsNumeric(?obj) AS ?IsNumeric) WHERE { ?s ?p ?obj }");
Object results = store.ExecuteQuery(q);
Assert.IsTrue(results is SparqlResultSet, "Result should be a SPARQL Result Set");
TestTools.ShowResults(results);
}
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:SparqlNewFunctions.cs
示例15: RepresentativeTable
// Constructor for creating a new representative table. We directly fill the table depending on the given sequence.
public RepresentativeTable(Graph graph, Tree tree)
{
// Initialize the table
_table = new Dictionary<BitSet, RepresentativeList>();
Queue<BitSet> queue = new Queue<BitSet>();
queue.Enqueue(tree.Root);
_table[new BitSet(0, graph.Size)] = new RepresentativeList();
int i = 0;
while (queue.Count != 0)
{
BitSet node = queue.Dequeue();
FillTable(graph, node);
FillTable(graph, graph.Vertices - node);
if (tree.LeftChild.ContainsKey(node))
{
queue.Enqueue(tree.LeftChild[node]);
}
if (tree.RightChild.ContainsKey(node))
{
queue.Enqueue(tree.RightChild[node]);
}
}
}
开发者ID:Miloan,项目名称:BooleanWidth,代码行数:29,代码来源:RepresentativeTable.cs
示例16: ShouldReplaceLinkInAll
public void ShouldReplaceLinkInAll()
{
// arrange
var source = new SampleNode("source");
var target = new SampleNode("target");
var graph = new Graph();
graph.AddNode(source);
graph.AddNode(target);
var firstLink = new SampleLink();
graph.AddLink(source, target, firstLink);
var secondLink = new SecondLink();
// act
graph.ReplaceLink(firstLink, secondLink);
// Assert
Assert.That(graph.Links, Has.Count.EqualTo(1));
Assert.That(graph.Links, Has.No.Member(firstLink));
Assert.That(graph.Links, Has.Member(secondLink));
Assert.That(secondLink.Source, Is.SameAs(source));
Assert.That(secondLink.Target, Is.SameAs(target));
Assert.That(source.OutboundLinks, Has.No.Member(firstLink));
Assert.That(target.InboundLinks, Has.No.Member(firstLink));
Assert.That(source.OutboundLinks, Has.Member(secondLink));
Assert.That(target.InboundLinks, Has.Member(secondLink));
}
开发者ID:Novakov,项目名称:HighLevelCodeAnalysis,代码行数:33,代码来源:GraphTest.cs
示例17: GetEditor
GraphGUIEx GetEditor(Graph graph)
{
GraphGUIEx graphGUI = ScriptableObject.CreateInstance<GraphGUIEx>();
graphGUI.graph = graph;
graphGUI.hideFlags = HideFlags.HideAndDontSave;
return graphGUI;
}
开发者ID:osmanzeki,项目名称:bmachine,代码行数:7,代码来源:GraphEditorWindow.cs
示例18: StatisticGraph
public StatisticGraph(Control parent, SpriteFont font, Statistic statistic, TimeSpan accessInterval)
: base(parent)
{
if (statistic == null)
throw new ArgumentNullException("statistic");
if (accessInterval == TimeSpan.Zero)
accessInterval = TimeSpan.FromMilliseconds(16);
Strata = new ControlStrata() { Layer = Layer.Overlay };
_tracker = new StatisticTracker(statistic, accessInterval);
_graph = new Graph(Device, (int)(15f / (float)accessInterval.TotalSeconds)); //(byte)MathHelper.Clamp(15f / (float)accessInterval.TotalSeconds, 15, 15 * 60));
_label = new Label(this, font) {
Text = statistic.Name,
Justification = Justification.Centre
};
_label.SetPoint(Points.TopLeft, 2, 2);
_label.SetPoint(Points.TopRight, -2, 2);
_value = new Label(this, font) {
Text = "0",
Justification = Justification.Centre
};
_value.SetPoint(Points.BottomLeft, 2, -2);
_value.SetPoint(Points.BottomRight, -2, -2);
_texture = new Texture2D(Device, 1, 1);
_texture.SetData<Color>(new Color[] { new Color(0, 0, 0, 0.8f) });
SetSize(200, 120);
}
开发者ID:xoxota99,项目名称:Myre,代码行数:31,代码来源:StatisticGraph.cs
示例19: AddEdgeFromVerticesExample
public void AddEdgeFromVerticesExample()
{
// Initialize a new graph instance
var graph = new Graph<int>(true);
// Add two vertices to the graph
var vertex1 = graph.AddVertex(1);
var vertex2 = graph.AddVertex(2);
// Add the edge to the graph
var edge = graph.AddEdge(vertex1, vertex2);
// The from vertex will be vertex1
Assert.AreEqual(edge.FromVertex, vertex1);
// The to vertex will be vertex2
Assert.AreEqual(edge.ToVertex, vertex2);
// Since the graph is directed, the edge will
// be directed as well
Assert.AreEqual(edge.IsDirected, true);
// The edge will be accessible though the edges collection
Assert.AreEqual(graph.Edges.Count, 1);
}
开发者ID:havok,项目名称:ngenerics,代码行数:25,代码来源:GraphExamples.cs
示例20: aaaFakeLicenseDatabase
public void aaaFakeLicenseDatabase()
{
Assert.Throws<NoValidVelocityDBLicenseFoundException>(() =>
{
using (SessionNoServer session = new SessionNoServer(systemDir))
{
session.BeginUpdate();
Database database;
License license = new License("Mats", 1, null, null, null, 99999, DateTime.MaxValue, 9999, 99, 9999);
Placement placer = new Placement(License.PlaceInDatabase, 1, 1, 1);
license.Persist(placer, session);
for (uint i = 10; i < 20; i++)
{
database = session.NewDatabase(i);
Assert.NotNull(database);
}
session.Commit();
File.Copy(Path.Combine(systemDir, "20.odb"), Path.Combine(systemDir, "4.odb"));
session.BeginUpdate();
for (uint i = 21; i < 30; i++)
{
database = session.NewDatabase(i);
Assert.NotNull(database);
}
session.RegisterClass(typeof(VelocityDbSchema.Samples.Sample1.Person));
Graph g = new Graph(session);
session.Persist(g);
session.Commit();
}
});
}
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:31,代码来源:ADatabaseIteration.cs
注:本文中的Graph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论