# Using Networkx to draw graph

Author posted @ 2014年4月13日 14:51 in Python , 15232 阅读

Draw a directed graph using Networkx

Code :

try:
import matplotlib.pyplot as plt
except:
raise

import networkx as nx

G=nx.DiGraph()
# Add nodes by specifying their positions
# Add edges by defining weight and label

elarge=[(u,v) for (u,v,d) in G.edges(data=True) if d['weight'] >0.5] # solid edge
esmall=[(u,v) for (u,v,d) in G.edges(data=True) if d['weight'] <=0.5] # dashed edge

# Retrieve the positions from graph nodes and save to a dictionary
pos=nx.get_node_attributes(G,'pos')
# Draw nodes
nx.draw_networkx_nodes(G,pos,node_size=700, node_color='orange')

# Draw edges
nx.draw_networkx_edges(G,pos,edgelist=elarge, width=2, edge_color='g')
nx.draw_networkx_edges(G,pos,edgelist=esmall, arrows=False, width=3,
alpha=0.5,edge_color='b',style='dashed')

# Draw node labels
nx.draw_networkx_labels(G,pos,font_size=18,font_family='sans-serif')

# Draw edge labels
edge_labels =dict([((u, v), d['label'])
for u, v, d in G.edges(data=True)])

nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)

plt.axis('off')
plt.savefig("communication_authority_graph.eps", format='eps') # save as eps
plt.show() # display

References:

merckseo 说:
2021年10月10日 06:43

Best Social Plan is the most trusted company for providing social media marketing services. Best Social Plan

seo 说:
2021年10月29日 07:35

I can’t believe that this printing center has the ability to deliver my orders at an amazing speed. The print and the papers were both of high quality. https://www.digitekprinting.com/vinyl-banners this link to know more about their awesome services.

SEO 说:
2022年3月11日 07:17

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up. Leedon Green

SEO 说:
2022年4月09日 08:39

We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work. najbolji brokeri u hrvatskoj

SEO 说:
2022年4月17日 05:32

You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... Ki Residences

Pg slot สล็อต เว็บตร 说:
2022年7月14日 17:12

Pg Slot สล็อต เว็บตรง เว็บสล็อตออนไลน์ แตกง่ายจ่ายจริง แจกหนัก แตกหนัง กับ เว็บ pg-slot.game ของเรา ที่กำลังมาแรง แซงเว็บเกมอันดับต้น ๆ ไปหมดแล้ว สมัครสมาชิกได้แล้ววันนี้

NCERT Evs Sample Pap 说:
2022年9月16日 04:08

Environmental Education or Environmental Studies (EVS) was introduced from the foundation of education to enable students to understand the situations occurring around our surroundings without any difficulties. NCERT Evs Sample Paper Class 2 The subject refers to the neighbouring in which all life, also makes use of to solve day-to-day challenges involving the environmental elements.To get a complete analysis of examination question pattern and to get ready to write an exam with confidence, subject experts of the NCERT has provided the Class 2 EVS Sample Paper 2023 with study & learning material that supports all formats of exams held under Term-1, Term-2 and other types of exams for every interested candidate.

NCERT Evs Sample Pap 说:
2022年9月16日 04:10

Environmental Education or Environmental Studies (EVS) was introduced from the foundation of education to enable students to understand the situations occurring around our surroundings without any difficulties. NCERT Evs Sample Paper Class 2 The subject refers to the neighbouring in which all life, also makes use of to solve day-to-day challenges involving the environmental elements.To get a complete analysis of examination question pattern and to get ready to write an exam with confidence, subject experts of the NCERT has provided the Class 2 EVS Sample Paper 2023 with study & learning material that supports all formats of exams held under Term-1, Term-2 and other types of exams for every interested candidate.

Top SEO 说:
2023年7月10日 18:40

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. https://ulnames.com/military-team-names/

Top SEO 说:
2023年7月10日 18:44

Personally I think overjoyed I discovered the blogs. https://www.adiwarna.co.id/fire-suppression-system/

Top SEO 说:
2023年7月19日 20:47

I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... Fun 88

sa 说:
2023年7月21日 18:57 I don t have the time at the moment to fully read your site but I have bookmarked it and also add your RSS feeds. I will be back in a day or two. thanks for a great site. rental mobil banyuwangi
sa 说:
2023年7月21日 21:23

It is the intent to provide valuable information and best practices, including an understanding of the regulatory process. Jun88

sa 说:
2023年7月23日 16:20 It's late finding this act. At least, it's a thing to be familiar with that there are such events exist. I agree with your Blog and I will be back to inspect it more in the future so please keep up your act. ns2121 login
sa 说:
2023年7月23日 17:05

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. slot gacor hari ini

sa 说:
2023年7月23日 18:05

Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. Streetwear clothing

sa 说:
2023年7月23日 19:05

Dalam era digital yang terus berkembang, kesempatan untuk menghasilkan uang secara online semakin beragam. Salah satu platform yang sangat populer untuk mencari penghasilan adalah YouTube. Bukan hanya para pembuat konten yang dapat menghasilkan uang melalui YouTube, tapi juga para penontonnya. aplikasi nonton youtube dapat uang

sa 说:
2023年7月24日 20:44 If you don"t mind proceed with this extraordinary work and I anticipate a greater amount of your magnificent blog entries dewacukong88
sa 说:
2023年7月24日 22:09

Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. ny zipline adventure tours hunter mountain

sa 说:
2023年7月26日 10:00

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon. elmer t lee for sale

sa 说:
2023年7月26日 10:51

A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Study Abroad Consultants in Trivandrum

a 说:
2023年7月27日 04:47

We are tied directly into the sate’s renewal database which allows us to process your request almost instantly. thevang1.net

Neutral Baby Shower 说:
2023年8月27日 19:43

Celebrate the upcoming arrival of a little one with our range of Neutral Baby Shower Gifts. These gifts are carefully curated to suit any baby shower theme or colour palette. From practical diaper bags to heartwarming story books, our neutral collection ensures that every gift is a delightful surprise, regardless of gender.

Local Taxi Services 说:
2023年8月27日 23:57

Exploring Saint Lucia is effortless with Tour Saint Lucia's local taxi services. Our knowledgeable drivers provide insights into the best local spots and attractions. Whether you're visiting landmarks, indulging in culinary delights, or shopping for souvenirs, our local taxi services make every journey enjoyable and informative.

sa 说:
2023年10月01日 18:54

Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Seo Ajansı

sa 说:
2023年10月03日 23:30 Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. trade digital assets
SEO 说:
2023年12月03日 22:08 Trust 커뮤니티 토토매치 for a safe and entertaining betting journey. Their transparency, quick payouts, and user-friendly platforms are unbeatable.
civaget 说:
2023年12月04日 08:02

백링크하이's commitment to quality backlinks is unmatched. They're a game-changer in the SEO industry.

civaget 说:
2023年12月07日 03:29

op사이트 순위 rankings are your gateway to online brilliance.

civaget 说:
2023年12月08日 23:08

오피가이드 ensures you're always in the loop about the latest OP trends. Trust it for accurate information and hassle-free OP exploration.

civaget 说:
2023年12月11日 03:55 Elevate your nightlife experiences with 오피가이드's user-generated content.
civaget 说:
2023年12月11日 04:03

안전카지노's gaming license is proof of its legitimacy. You're in safe hands here.

civaget 说:
2023年12月11日 20:47

I had an incredible experience with 제주출장마사지. The hot stone massage was divine, and their therapists are truly skilled.

civaget 说:
2023年12月11日 21:04

부산오피 caters to diverse tastes. Whether you're a local or a tourist, you'll find Officetels to suit your preferences.

civaget 说:
2023年12月11日 23:31

에볼루션카지노's live blackjack is my favorite. The professional dealers and high-quality streaming make it an exceptional experience. Try it for yourself!

civaget 说:
2023年12月12日 01:32

No more officetel guesswork with 오피가이드.

civaget 说:
2023年12月14日 05:29

Hey your site looks a little bit weird in Opera on my office computer Mac . NBA중계

civaget 说:
2023年12月15日 22:50

Oga's 출장마사지 is my go-to for relaxation. Their therapists are exceptional, and the convenience is unbeatable.

civaget 说:
2023年12月16日 02:20

밤의민족: Your night-time companion for 'OP' adventures and tranquil home Thai massages.

civaget 说:
2023年12月16日 23:21

대전오피's services are second to none. Every visit is a rejuvenating experience.

civaget 说:
2023年12月17日 04:47 I'm addicted to 해외축구중계. It's a one-stop-shop for all my soccer needs.
civaget 说:
2023年12月18日 04:17

Effortlessly find officetel wonders with 오피가이드. It's the officetel enthusiast's ultimate resource for discovering hidden gems.

civaget 说:
2023年12月18日 20:09

The user-friendly interface of 티비위키 is a breath of fresh air.

civaget 说:
2023年12月19日 22:30

Great weblog here! Also your web site lots up very fast! What host are you the usage of? Can I am getting your affiliate hyperlink for your host? I want my web site loaded up as fast as yours lol. 에볼루션카지노

civaget 说:
2023年12月20日 08:36

I read about 대전휴게텔 on The Insider's Views. It's as amazing as they described.

civaget 说:
2024年1月02日 04:23

오피가이드 is my trusted companion for discovering massage parlors in KOREA.

SEO 说:
2024年1月22日 22:29

This is my first-time i visit here. I found a multitude of entertaining stuff as part of your blog, especially its discourse. From the tons of comments on the posts, I guess I am not the only one having most of the enjoyment the following! Keep in the excellent job. The Presidential Family

SEO 说:
2024年1月22日 22:32

This is my first-time i visit here. I found a multitude of entertaining stuff as part of your blog, especially its discourse. From the tons of comments on the posts, I guess I am not the only one having most of the enjoyment the following! Keep in the excellent job. The Presidential Family

how to turn off do n 说:
2024年2月02日 17:50

Hello there, just became alert to your blog through Google, and found that it’s really informative. I’m going to watch out for brussels. I will be grateful if you continue this in future. A lot of people will be benefited from your writing. Cheers!

SEO 说:
2024年2月03日 20:15

Thanks so much regarding giving me personally an update on this subject matter on your site. Please know that if a completely new post becomes available or if perhaps any improvements occur on the current submission, I would consider reading a lot more and learning how to make good use of those techniques you discuss. Thanks for your time and consideration of other men and women by making this website available. holiday in cuba Büyükçekmece Escort

sar 说:
2024年2月07日 01:39

My husband and i were quite thrilled when Chris could finish up his investigations with the ideas he obtained out of the web site. It is now and again perplexing to simply possibly be giving out tactics which usually others could have been making money from. And we remember we have got the blog owner to give thanks to for that. The explanations you’ve made, the straightforward blog menu, the friendships you can aid to create – it is everything superb, and it is making our son and the family do think that idea is fun, and that’s pretty essential. Thanks for everything! <a href="https://www.jpost.com/brandblend/sugar-defender-reviews-fraud-or-legit-2024-beware-scam-warning-and-fake-side-effects-784867">Sugar Defender</a>

seo 说:
2024年2月10日 17:43

There is numerous separate years Los angeles Weight reduction eating plan with each a person is a necessity. The pioneer part can be your original getting rid of belonging to the extra pounds. la weight loss 인계동노래방

sar 说:
2024年2月11日 01:23

You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. sevilla

seo 说:
2024年2月11日 23:12

You’ve made various nice points there. I did specific search terms around the matter and found mainly individuals will believe your site Blox Fruits codes

seo 说:
2024年2月12日 00:20

I impressed, I must say. Actually hardly ever do I encounter a blog that each educative and entertaining, and let me let you know, you have got hit the nail on the head. Your concept is outstanding; the difficulty is something that not enough people are talking intelligently about. I am very glad that I stumbled across this in my search for something regarding this. Best price for battery tab

seo 说:
2024年2月12日 01:52

I was curious if you ever considered changing the page layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two pictures. Maybe you could space it out better? Napsgear

Sell NFT on TikTok 说:
2024年4月09日 14:18

Strange this post is totaly unrelated to what I was searching google for, but it surely was once indexed at the first page. I suppose your doing something proper if Google likes you enough to place you at the first page of a non related search. <a href="https://soundcamps.com/tiktok-music-promotion/">Sell NFT on TikTok</a>

integration testing 说:
2024年4月10日 02:17

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include.

roses delivery abu d 说:
2024年4月15日 06:13

I’m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site.

sportswear uae 说:
2024年4月18日 08:24

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include.

Bra dubai 说:
2024年4月18日 20:03

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include.

(输入验证码)
or Ctrl+Enter