当前位置:网站首页>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
边栏推荐
- Forkjoin and stream flow test
- 10 golang operator
- SystemVerilog learning-10-validation quantification and coverage
- Picture server project test
- webapck打包原理--启动过程分析
- B-tree series
- NOC 设计的一些坑
- C#如何打印输出原版数组
- 【Unity Shader 描边效果_案例分享第一篇】
- [automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
猜你喜欢
C language course set up student elective course system (big homework)
Student attendance system for C language course (big homework)
【企业数据安全】升级备份策略 保障企业数据安全
C language course design student information management system (big homework)
VS2019如何永久配置本地OpenCV4.5.5使用
FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview
C language course set up library information management system (big homework)
手把手教你实现一个深度学习框架...
Redis安装到Windows系统上的详细步骤
高阶-二叉搜索树详解
随机推荐
伪装请求头库: anti-useragent
【ManageEngine】终端管理系统,助力华盛证券数字化转型
10 golang operator
SQL statement
端口扫描工具是什么?端口扫描工具有什么用
sci-hub如何使用
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
解决The code generator has deoptimised the styling of xxxx.js as it exceeds the max of 500kb
启牛学堂合作的证券公司是哪家?开户安全吗?
Three minutes to quickly understand the whole process of website development
【网络安全工具】USB控制软件有什么用
mysql数据类型学习笔记
Detailed steps for installing redis on Windows system
【ManageEngine卓豪】局域网监控的作用
B-tree series
FPGA - clocking -02- clock wiring resources of internal structure of 7 Series FPGA
证券类开户有什么影响 开户安全吗
Code power is full of quantitative learning | how to find a suitable financial announcement in the financial report
Promise