本文整理汇总了C#中Microsoft.Msagl.Drawing.Graph.AddEdge方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.AddEdge方法的具体用法?C# Graph.AddEdge怎么用?C# Graph.AddEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Msagl.Drawing.Graph
的用法示例。
在下文中一共展示了Graph.AddEdge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindow_Loaded
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
GraphViewer graphViewer = new GraphViewer();
graphViewer.BindToPanel(Panel);
Graph graph = new Graph();
graph.AddEdge("A", "B");
graph.Attr.LayerDirection = LayerDirection.LR;
graphViewer.Graph = graph; // throws exception
}
示例2: SomeClass
public static void SomeClass()
{
var graph = new MSAGL.Drawing.Graph("");
graph.AddEdge("A", "B");
graph.AddEdge("A", "B");
graph.FindNode("A").Attr.FillColor = MSAGL.Drawing.Color.BlanchedAlmond;
graph.FindNode("B").Attr.FillColor = MSAGL.Drawing.Color.BurlyWood;
var renderer = new MSAGL.GraphViewerGdi.GraphRenderer(graph);
renderer.CalculateLayout();
const int width = 50;
int height = (int)(graph.Height * (width / graph.Width));
const PixelFormat pixfmt = System.Drawing.Imaging.PixelFormat.Format32bppPArgb;
using (var bitmap = new System.Drawing.Bitmap(width, height, pixfmt))
{
using (var gfx = System.Drawing.Graphics.FromImage(bitmap))
{
gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
var rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
renderer.Render(gfx, rect);
bitmap.Save("test.png");
}
}
}
示例3: DrawGraph
void DrawGraph(Automaton automaton)
{
var graph = new Graph();
graph.Attr.LayerDirection = LayerDirection.LR;
int i = 0;
foreach (var s in automaton.States)
{
foreach (var o in s.Output)
{
var index = automaton.States.IndexOf(o.End);
var end = ReferenceEquals(automaton.StartState, o.End) ? "Start" : index.ToString();
if (ReferenceEquals(s, automaton.StartState))
{
graph.AddEdge("Start", o.ToString(), end);
}
else if (o.End.IsFinalState)
{
graph.AddEdge(i.ToString(), o.ToString(), "End");
}
else
{
graph.AddEdge(i.ToString(), o.ToString(), end);
}
}
i++;
}
graphViewer.Graph = graph;
}
示例4: CopyGraph
/// <summary>
/// Copies a graph and its GeometryGraph.
/// </summary>
/// <param name="parentGraph"></param>
/// <returns></returns>
public static Graph CopyGraph(Graph parentGraph)
{
GeometryGraph geometryCopy = CopyGraph(parentGraph.GeometryGraph);
Graph graph=new Graph();
graph.GeometryGraph = geometryCopy;
Dictionary<Node,int> nodeId=new Dictionary<Node, int>(geometryCopy.Nodes.Count);
for (int i = 0; i < geometryCopy.Nodes.Count; i++) {
nodeId[geometryCopy.Nodes[i]] = i;
String id = i.ToString();
graph.AddNode(id);
var node = graph.FindNode(id);
node.GeometryNode = geometryCopy.Nodes[i];
geometryCopy.Nodes[i].UserData = node;
}
foreach (var edge in geometryCopy.Edges) {
String sourceId = nodeId[edge.Source].ToString();
String targetId = nodeId[edge.Target].ToString();
var edgeCopy=graph.AddEdge(sourceId, "", targetId);
edgeCopy.GeometryEdge = edge;
edge.UserData = edgeCopy;
}
return graph;
}
示例5: Form1
public Form1()
{
InitializeComponent();
GViewer gViewer = new GViewer() { Dock = DockStyle.Fill };
SuspendLayout();
Controls.Add(gViewer);
ResumeLayout();
Graph graph = new Graph();
var sugiyamaSettings = (SugiyamaLayoutSettings)graph.LayoutAlgorithmSettings;
sugiyamaSettings.NodeSeparation *= 2;
graph.AddEdge("A", "B");
graph.AddEdge("A", "C");
graph.AddEdge("A", "D");
graph.LayerConstraints.PinNodesToSameLayer(new[] { graph.FindNode("A"), graph.FindNode("B"), graph.FindNode("C") });
gViewer.Graph = graph;
}
示例6: ModulesGraph
private void ModulesGraph()
{
Graph g = new Graph();
using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
{
command.CommandText = @"select name from modules";
SQLiteDataReader DataReader = command.ExecuteReader();
while (DataReader.Read())
g.AddNode(DataReader["name"].ToString());
}
using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
{
command.CommandText = @"select * from moddeps";
SQLiteDataReader DataReader = command.ExecuteReader();
while (DataReader.Read())
{
Microsoft.Msagl.Drawing.Edge e = g.AddEdge(DataReader["used"].ToString(), "", DataReader["uses"].ToString());
e.Attr.LineWidth = int.Parse(DataReader["count"].ToString());
//e.Attr.Color = Microsoft.Msagl.Drawing.Color.Yellow;
e.LabelText = DataReader["rate"].ToString();
}
}
gViewer.Graph = g;
}
示例7: ToMsaglGraph
public static Microsoft.Msagl.Drawing.Graph ToMsaglGraph(this Graph g) {
var msaglGraph = new Microsoft.Msagl.Drawing.Graph();
for (var v = 0; v < g.V; v++) {
foreach (var w in g.AdjacentVertices(v)) {
var e = msaglGraph.AddEdge(v.ToString(), w.ToString());
e.SourceNode.Attr.Shape = Shape.Circle;
e.TargetNode.Attr.Shape = Shape.Circle;
}
}
return msaglGraph;
}
示例8: ReadEdge
static void ReadEdge(Graph graph, StreamReader f) {
f.ReadLine();
var s = f.ReadLine();
s = s.Trim(' ', '\t', '"');
var source = s.Split(' ')[1];
s = f.ReadLine();
s = s.Trim(' ', '\t', '"');
var target = s.Split(' ')[1];
graph.AddEdge(source, target);
f.ReadLine();
}
示例9: PatchGraph
private void PatchGraph(int id)
{
Graph g = new Graph();
using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
{
command.CommandText = @"select name from modules";
SQLiteDataReader DataReader = command.ExecuteReader();
while (DataReader.Read())
g.AddNode(DataReader["name"].ToString());
}
using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
{
command.CommandText = @"select * from patchview where [email protected]_id";
command.Parameters.Add(new SQLiteParameter("@patch_id", id));
SQLiteDataReader DataReader = command.ExecuteReader();
while (DataReader.Read())
{
Microsoft.Msagl.Drawing.Edge e = g.AddEdge(DataReader["used"].ToString(), "", DataReader["uses"].ToString());
e.Attr.LineWidth = int.Parse(DataReader["count"].ToString());
e.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
e.LabelText = DataReader["rate"].ToString();
}
}
using (SQLiteCommand command = new SQLiteCommand(ConnectionManager.connection))
{
command.CommandText = @"select * from patchview2 where [email protected]_id";
command.Parameters.Add(new SQLiteParameter("@patch_id", id));
SQLiteDataReader DataReader = command.ExecuteReader();
while (DataReader.Read())
{
Microsoft.Msagl.Drawing.Edge e = g.AddEdge(DataReader["used"].ToString(), "", DataReader["uses"].ToString());
e.Attr.LineWidth = int.Parse(DataReader["count"].ToString());
e.Attr.Color = Microsoft.Msagl.Drawing.Color.Yellow;
e.LabelText = (int.Parse(DataReader["rate"].ToString())/10).ToString();
}
}
gViewer.Graph = g;
}
示例10: DrawAutoma
private void DrawAutoma(AutomaFuzzy.Automa<Symbol> automma)
{
Graph graph = new Graph("Automa");
//graph.GraphAttr.Backgroundcolor = Microsoft.Glee.Drawing.Color.Black;
for (int i = 0; i < automma.States.Count; i++)
{
string str = automma.States[i].ToString();
Node no = graph.AddNode(automma.States[i].Name);
no.Attr.Shape = Shape.Box;
no.LabelText = str;
}
foreach (var transition in automma.Transitions)
{
string symbol = ((CompilerWithFuzzy.AutomaFuzzy.Rules.SimpleIncludeRule<Symbol>)transition.Rule).Symbol.ToString();
string label =
((CompilerWithFuzzy.AutomaFuzzy.Rules.SimpleIncludeRule<Symbol>)transition.Rule).Symbol.ToString() +
" - " + transition.Rule.Pertinence.ToString();
label = symbol;
Edge arco = graph.AddEdge(transition.From.Name, label
, transition.To.Name);
System.Drawing.Color c = Utils.GetColor(transition.Rule.Pertinence);
var color = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
arco.Attr.Color = color;
//arco.Attr.Fontcolor = color;
arco.Attr.AddStyle(Style.Bold);
arco.Attr.LineWidth = 5;
}
GViewer viewer = new GViewer();
viewer.NavigationVisible = false;
viewer.OutsideAreaBrush = Brushes.White;
viewer.ToolBarIsVisible = false;
viewer.Graph = graph;
viewer.Dock = System.Windows.Forms.DockStyle.Fill;
pnlAutoma.Controls.Clear();
pnlAutoma.Controls.Add(viewer);
}
示例11: Draw
private void Draw(Automa<char> automa, int indexTable = -1)
{
Graph graphAutoma = new Graph("Automa");
for (int i = 0; i < automa.States.Count; i++)
{
State<char> state = automa.States[i];
Node no = graphAutoma.AddNode(state.Name);
no.Attr.Shape = Shape.Circle;
if (state.PertinenceFinal > 0)
{
no.Attr.Shape = Shape.DoubleCircle;
}
if (indexTable > -1)
{
System.Drawing.Color c = Utils.GetColor(regexFuzzy.TableAutomaProcessing[indexTable][i]);
no.Attr.FillColor = new Microsoft.Msagl.Drawing.Color((byte)c.R, (byte)c.G, (byte)c.B);
}
else if (state.PertinenceInitial > 0)
{
no.Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightGray;
}
}
foreach (var transition in automa.Transitions)
{
Edge arco = graphAutoma.AddEdge(transition.From.Name, transition.To.Name);
arco.LabelText = transition.ToString();
}
GViewer viewer = new GViewer();
viewer.NavigationVisible = false;
viewer.OutsideAreaBrush = Brushes.White;
viewer.ToolBarIsVisible = false;
viewer.Graph = graphAutoma;
viewer.Dock = System.Windows.Forms.DockStyle.Fill;
pnlAutoma.Controls.Clear();
pnlAutoma.Controls.Add(viewer);
}
示例12: BindEdges
static void BindEdges(Graph graph, GeometryGraph geomGraph, Dictionary<GeomNode, string> nodeIds) {
foreach (var edge in geomGraph.Edges) {
if (IsUnderCollapsedCluster(edge))
continue;
var e = graph.AddEdge(nodeIds[edge.Source], nodeIds[edge.Target]);
if (edge.EdgeGeometry != null && edge.EdgeGeometry.SourceArrowhead != null)
e.Attr.ArrowheadAtSource = ArrowStyle.Normal;
e.Attr.ArrowheadAtTarget = edge.EdgeGeometry != null && edge.EdgeGeometry.TargetArrowhead != null
? ArrowStyle.Normal
: ArrowStyle.None;
e.GeometryEdge = edge;
e.Attr.LineWidth = edge.LineWidth;
if (edge.Label != null && edge.Label.Width != 0) {
e.LabelText = "label";
e.Label.GeometryLabel = edge.Label;
e.Label.Owner = e;
}
}
}
示例13: SimulationInitialize
private void SimulationInitialize(bool moveFirsStep)
{
//clear the trace and visited table
Traces.Clear();
visited.Clear();
ListView_Trace.Items.Clear();
//get the starting process
//create the initial step
EventStepSim initialStep = new EventStepSim(Spec.SimulationInitialization(this.ComboBox_Process.Text));
//new EventStepSim(startingProcess, Common.Ultility.Constants.INITIAL_EVENT, null, SpecProcess.GetEnvironment()));
//use the process string as the definition ref string, this is the only special case needs to be taken care of
//initialStep.ProcessToString = startingProcess.Def.ToString();
//todo: tobe checked
//initialStep.ProcessToString = startingProcess.ToString();
InitialState = initialStep.StepID;
//string initialLabel = initialStep.ToFullString();
AddToTrace("0", initialStep, "1", InitialState);
CurrentEnableEventList.Clear();
if (moveFirsStep)
{
//try
//{
List<EventStepSim> list = initialStep.MakeOneMove(HideTauTransition);
for (int i = 0; i < list.Count; i++)
{
EventStepSim step = list[i];
step.SourceProcess = InitialState;
step.IsUnvisitedStep = true;
list[i] = step;
}
CurrentEnableEventList.AddRange(list);
//}
//catch (Exception ex)
//{
//}
}
visited.Add(InitialState, null);
g = new Graph("Graph");
//g.GraphAttr.Orientation = System.Windows.Forms.Orientation.Landscape;
g.Attr.LayerDirection = Direction;
Node n = g.AddNode(InitialState);
n.Attr.FillColor = Color.Red;
n.LabelText = "1";
n.UserData = initialStep; //initialLabel;
Node tempN = g.AddNode(INITIAL_STATE);
tempN.Attr.LineWidth = 0;
tempN.Attr.Color = Color.White;
tempN.LabelText = "";
tempN.UserData = "";
g.AddEdge(INITIAL_STATE, InitialState);
//clear the mapping table
Mapping.Clear();
Mapping.Add(GetTraceEvent(this.ListView_Trace.Items.Count) + InitialState,
new ProcessData(initialStep, CloneGraph(g), CloneEnabledEvent()));
SimulatorViewer.Graph = g;
SimulatorViewer.Validate();
FillCurrentEnabledList();
UpdateStore(initialStep);
WarningFlag = false;
}
示例14: CreateWideGraph
void CreateWideGraph()
{
graph = new Graph();
for (int i = 0; i < 100; i++)
graph.AddEdge("A", i.ToString());
}
示例15: InitGraph
private void InitGraph()
{
Graph drawingGraph = new Graph();
drawingGraph.AddEdge(leavesId, creekId);
drawingGraph.AddEdge(leavesId, treeId);
drawingGraph.AddEdge(leavesId, wId);
drawingGraph.AddEdge("uno", "otro");
foreach (DrawingNode node in drawingGraph.Nodes)
{
if (!node.Id.Equals("uno"))
{
node.Attr.Shape = Shape.DrawFromGeometry;
node.DrawNodeDelegate = new DelegateToOverrideNodeRendering(DrawNode);
node.NodeBoundaryDelegate = new DelegateToSetNodeBoundary(GetNodeBoundary);
}
else
{
node.LabelText = "node with a diamond shape";
node.Attr.Shape = Shape.Diamond;
}
}
double width = leaves.Width;
double height = leaves.Height;
drawingGraph.Attr.LayerSeparation = height / 2;
drawingGraph.Attr.NodeSeparation = width / 2;
double arrowHeadLenght = width / 10;
foreach (Microsoft.Msagl.Drawing.Edge e in drawingGraph.Edges)
e.Attr.ArrowheadLength = (float)arrowHeadLenght;
drawingGraph.LayoutAlgorithmSettings = new SugiyamaLayoutSettings();
viewer.Graph = drawingGraph;
}