当前位置:网站首页>Draw a directed graph based on input
Draw a directed graph based on input
2022-07-01 06:28:00 【Keep--Silent】
List of articles
explain
Draw one directly from the input mermaid
Source code
#include <bits/stdc++.h>
using namespace std;
int main() {
int m, j,v,w,x;
map<int, map<int, int> >g;
cin >> m;
while (m--) {
cin >> v >> w >> x;
g[v][w] = x;
//g[w][v]=x;
}
set<int>st;
vector<int>t(3, 0);
vector<vector<int>>vt;
for (auto p1:g) {
st.insert(p1.first);
for (auto p2 : p1.second) {
st.insert(p2.first);
vt.push_back(vector<int>{
p1.first,p2.first,p2.second});
}
}
printf("```mermaid\ngraph TD\n");
for (auto x : st) {
printf("%d([%d])\n",x,x);
}
for (auto v : vt) {
printf("\t%d -->|%d| %d\n",v[0],v[2],v[1]);
}
printf("```\n");
return 0;
}
Input and output
7
1 2 2
1 5 1
2 3 1
2 4 1
2 5 2
3 5 1
3 4 1
```mermaid
graph TD
1([1])
2([2])
3([3])
4([4])
5([5])
1 -->|2| 2
1 -->|1| 5
2 -->|1| 3
2 -->|1| 4
2 -->|2| 5
3 -->|1| 4
3 -->|1| 5
```
effect
边栏推荐
- lxml模块(数据提取)
- Lxml module (data extraction)
- mysql数据类型学习笔记
- 【ManageEngine卓豪】移动终端管理解决方案,助力中州航空产业数字化转型
- 【Unity Shader 描边效果_案例分享第一篇】
- C language course is provided with employee information management system (large operation)
- 子类调用父类的同名方法和属性
- ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
- [unity shader ablation effect _ case sharing]
- 【ManageEngine】终端管理系统,助力华盛证券数字化转型
猜你喜欢

C language course design student information management system (big homework)

HCM Beginner (II) - information type

Redis安装到Windows系统上的详细步骤

HCM Beginner (I) - Introduction

JMM详解

Free trial of self-developed software noisecreater1.1
![[ITSM] what is ITSM and why does it department need ITSM](/img/e1/85b5f00f124829b6a6b40c5cf621bd.png)
[ITSM] what is ITSM and why does it department need ITSM

IT服务管理(ITSM)在高等教育领域的应用

C language course set up library information management system (big homework)

Uniapp tree level selector
随机推荐
Excel visualization
SystemVerilog learning-08-random constraints and thread control
Promise
VS2019如何永久配置本地OpenCV4.5.5使用
Uniapp tree level selector
端口扫描工具对企业有什么帮助?
Mysql 表分区创建方法
JSON module
NOC 设计的一些坑
[ITSM] what is ITSM and why does it department need ITSM
C语言课设工资管理系统(大作业)
SQL语言的学习记录一
Forkjoin and stream flow test
【#Unity Shader#自定义材质面板_第一篇】
H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结
端口扫描工具是什么?端口扫描工具有什么用
存储函数学习笔记
码力十足学量化|如何在财务报告寻找合适的财务公告
伪装请求头库: anti-useragent
微信公众号内嵌跳转微信小程序方案总结