当前位置:网站首页>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
边栏推荐
- Minio error correction code, construction and startup of distributed Minio cluster
- C language course set up library information management system (big homework)
- Forkjoin and stream flow test
- C language course set up student elective course system (big homework)
- SQL中DML语句(数据操作语言)
- [automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
- 【#Unity Shader#Amplify Shader Editor(ASE)_第九篇】
- 【ManageEngine卓豪】网络运维管理是什么,网络运维平台有什么用
- NOC 设计的一些坑
- Functions of switch configuration software
猜你喜欢

下载外文期刊的方法

概率论学习笔记

Forkjoin and stream flow test

To sort out the anomaly detection methods, just read this article!

How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?

C语言课设销售管理系统设计(大作业)

【#Unity Shader#自定义材质面板_第二篇】
![[unity shader stroke effect _ case sharing first]](/img/bd/5cd1bef24e6b6378854114c2c05bd9.png)
[unity shader stroke effect _ case sharing first]

SQL statement
![[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform](/img/14/756d566744d6e4a988a284c5b30130.png)
[automatic operation and maintenance] what is the use of the automatic operation and maintenance platform
随机推荐
JSON module
10 golang operator
【ManageEngine卓豪】用统一终端管理助“欧力士集团”数字化转型
C语言课设物业费管理系统(大作业)
C语言课设职工信息管理系统(大作业)
SQL中DML语句(数据操作语言)
SQL statement
ManageEngine卓豪助您符合ISO 20000标准(四)
Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
C language course set up student elective course system (big homework)
Promise
【ManageEngine】终端管理系统,助力华盛证券数字化转型
C语言课设工资管理系统(大作业)
Treasure taking from underground palace (memory based deep search)
FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview
C#如何打印輸出原版數組
Internet worm
基金定投是高风险产品吗?
[ManageEngine] how to realize network automatic operation and maintenance
Requests module (requests)