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怎么建立矩阵
  • 热门搜索
    凌潇肃和姚晨怎么回事 诉状怎么写 胸围怎么算 手脚麻木怎么办 小孩发烧怎么物理降温 党费怎么交 怎么用手机赚钱 手脱皮怎么治 正方体的表面积怎么求 小学生怎么赚钱