Mathematica基础——GraphPlot

 时间:2024-10-15 10:43:40

1、比如下图,虽然代码里面显示,图应该是有向图,但结果却没有明确指定方向:GraphPlot[{1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 8 -> 1, 8 -> 2, 8 -> 8}]

Mathematica基础——GraphPlot

2、如果需要把图的方向画出来,需要用DirectedEdges->True来指定。GraphPlot[{1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 8 -> 1, 8 -> 2, 8 -> 8},DirectedEdges -> True]DirectedEdges的意思是,有方向的边。

Mathematica基础——GraphPlot

3、如果需要写出各顶点的标签,需要用VertexLabeling -> True来限制:GraphPlot[{1 -> 2, 2 幻腾寂埒-> 1, 3 -> 1, 3 -> 2, 8 -> 1, 8 -> 2, 8 -> 8}, DirectedEdges -> True, VertexLabeling -> True]VertexLabeling的意思是,标注顶点。

Mathematica基础——GraphPlot

4、用下面的代码,可以为某一条边加上标签:GraphPlot[{1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 8 -> 1, 8 -> 2, {8 -> 8,"8到8"}},DirectedEdges -> True, VertexLabeling -> True]

Mathematica基础——GraphPlot

5、Mathematica可以轻松地绘制出一个36阶的完全图,感觉有点密集:GraphPlot[Table[1, {20}, {20}]]

Mathematica基础——GraphPlot

6、所以,用EdgeRenderingFunction -> None取消边的绘制,只留下36个顶点:GraphPlot[Table[1, {20}, {20}], EdgeRenderingFunction -> None]

Mathematica基础——GraphPlot
  • Excel怎么使用平方根函数SQRT
  • 一个函数返回来两个值怎么做
  • python交互模式怎么打开
  • matlab怎么建立矩阵
  • 热门搜索
    诚实手抄报 交通手抄报的内容 平安校园手抄报资料 中秋手抄报图片大全 安全伴我成长手抄报 有关长城的手抄报 三年级下册手抄报大全 关于对联的手抄报 数学天地手抄报 走进名人手抄报