LeonceNsh commited on
Commit
99eb020
·
verified ·
1 Parent(s): 85296ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -51
app.py CHANGED
@@ -1,5 +1,3 @@
1
- # venture_networks_gradio.py
2
-
3
  import networkx as nx
4
  import matplotlib.pyplot as plt
5
  import gradio as gr
@@ -10,27 +8,7 @@ from PIL import Image
10
  investors = {
11
  "Accel": ["Meta", "Dropbox", "Spotify", "Adroll", "PackLink", "Zoom", "Slack"],
12
  "Andreessen Horowitz": [
13
- "Airbnb", "Lyft", "Pinterest", "Accolade", "Actifio", "Affirm", "Amify",
14
- "Apptio", "Arimo", "Asana", "Asserts", "Authy", "Automatic", "Barefoot Networks",
15
- "Bebop", "BeReal", "Blockspring", "Boku", "Box", "Bracket Computing", "Bump",
16
- "BuzzFeed", "Capital", "Cardiogram", "Caviar", "Citiizen", "CipherCloud",
17
- "ClearStory", "Coinbase", "Cumulus", "DeepMap", "Delphix", "DigitalOcean",
18
- "Dollar Shave Club", "Earn", "EQRx", "Erasca", "Meta", "FiftyThree", "Flutter",
19
- "Fusion-io", "Gainspeed", "Genius", "GitHub", "Gobble", "Golden", "Greenlight",
20
- "Granular", "Greplify", "Groupon", "Hatch", "iCracked", "Imgur", "Instacart",
21
- "Instagram", "Intrinsic", "Isovalent", "Jopwell", "Julep", "Jungla", "Keybase",
22
- "Kno", "Knowable", "Knowmia", "Loom", "Lowkey", "Luma", "Lyrebird", "Lytro",
23
- "Massive", "Morta Security", "Nautilus Biotechnology", "Nicira", "Oculus", "Okta",
24
- "Onshape", "Opendoor", "OpenInvest", "Optimizely", "Optimyze", "PagerDuty",
25
- "Parsec", "Patch Biosciences", "PatientPing", "PicCloud", "Pinterest", "Pixate",
26
- "Platfora", "Product Hunt", "Quantopian", "RHL Ventures", "Reddit", "Reflektive",
27
- "Rigetti", "Rival", "Robinhood", "Roblox", "Rockmelt", "RTFKT", "Samsara", "Seed",
28
- "Shapeways", "ShoeDazzle", "SignalFx", "SigOpt", "Silver Tail Systems", "Skout",
29
- "Skype", "Slack", "Socialcam", "Soylent", "Stack Overflow", "Standard Treasury",
30
- "Swell", "Swiftype", "Tabular", "Talaria", "Tasty Labs", "Teleport", "Tenfold",
31
- "Tidemark", "Tilt", "TinyCo", "Tmunity", "Tomfoolery", "Wise", "TXN", "Urban Engines",
32
- "Usermind", "Viki", "Walker and Company", "Wit.ai", "Within", "Zynga", "Altitude Learning",
33
- "Bromium", "Factual", "Instart", "Proven", "Rabbit", "UnifyID"
34
  ],
35
  "Google Ventures": ["Uber", "LendingClub"],
36
  "Greylock": ["Workday", "Palo Alto Networks"],
@@ -40,43 +18,63 @@ investors = {
40
  "Emergence Capital Partners": ["Zoom", "Box", "Salesforce"],
41
  "Trinity Ventures": ["New Relic", "Care.com", "TubeMogul"],
42
  "Citi Ventures": ["Square", "Nutanix"],
43
- "Sequoia": [
44
- "Alphabet (Google)", "NVIDIA", "Dropbox", "Airbnb", "Affirm",
45
- "Airbnb", "Eventbrite", "Meta", "Lyft", "Opendoor", "Palantir", "Reddit", "Uber",
46
- "23ANDME", "AMPLITUDE", "APPLE", "ATARI", "AURORA", "BARRACUDA", "BIRD", "BLOCK",
47
- "BRIDGEBIO", "CISCO", "CONFLUENT", "DOORDASH", "ELECTRONIC ARTS", "FIREEYE", "GOOGLE",
48
- "GREEN DOT", "GUARDANT HEALTH", "HUBSPOT", "INSTACART", "LINKEDIN", "MEDALLIA", "MONGODB",
49
- "NATERA", "NETAPP", "NIMBLE STORAGE", "NUBANK", "OKTA", "ORACLE", "PALO ALTO NETWORKS",
50
- "PAYPAL", "QUALTRICS", "QUANTENNA", "RINGCENTRAL", "ROBINHOOD", "RUCKUS NETWORKS",
51
- "SERVICENOW", "SNOWFLAKE", "SUMO LOGIC", "SUNRUN", "TRULIA", "UIPATH", "UNITY", "YAHOO"
52
- ],
53
- "Y Combinator": ["Dropbox", "Airbnb", "Coinbase", "DoorDash", "Reddit", "Ginkgo Bioworks", "GitLab", "Instacart"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
 
 
 
56
  # Define a color map for the investors
57
  investor_colors = {
58
- "Accel": "lightblue",
59
- "Andreessen Horowitz": "lightgreen",
60
- "Google Ventures": "lightred",
61
- "Greylock": "purple",
62
- "Lightspeed Venture Partners": "orange",
63
- "Benchmark": "lightbrown",
64
- "Norwest Venture Partners": "pink",
65
- "Emergence Capital Partners": "yellow",
66
- "Trinity Ventures": "cyan",
67
- "Citi Ventures": "magenta",
68
- "Sequoia": "lime",
69
- "Y Combinator": "black"
70
  }
71
 
72
-
73
  def generate_graph(selected_investors):
74
  if not selected_investors:
75
  selected_investors = list(investors.keys())
76
 
77
  G = nx.Graph()
78
 
79
- # Add edges based on selected investors
80
  for investor in selected_investors:
81
  companies = investors[investor]
82
  for company in companies:
@@ -85,13 +83,16 @@ def generate_graph(selected_investors):
85
  # Get edge colors
86
  edge_colors = [G[u][v]['color'] for u, v in G.edges]
87
 
88
- # Set node colors: investors have their specific color, companies have a default color
89
  node_colors = []
 
90
  for node in G.nodes:
91
  if node in investor_colors:
92
  node_colors.append(investor_colors[node])
 
93
  else:
94
  node_colors.append("#F0E68C") # Khaki for companies
 
95
 
96
  # Create plot
97
  plt.figure(figsize=(18, 18))
@@ -99,7 +100,7 @@ def generate_graph(selected_investors):
99
  nx.draw(
100
  G, pos,
101
  with_labels=True,
102
- node_size=3000,
103
  node_color=node_colors,
104
  font_size=10,
105
  font_weight="bold",
@@ -133,7 +134,7 @@ def main():
133
  ),
134
  outputs=gr.Image(type="pil", label="Venture Network Graph"),
135
  title="Venture Networks Visualization",
136
- description="Select investors to visualize their investments in various companies. The graph shows connections between investors and the companies they've invested in.",
137
  flagging_mode="never"
138
  )
139
 
 
 
 
1
  import networkx as nx
2
  import matplotlib.pyplot as plt
3
  import gradio as gr
 
8
  investors = {
9
  "Accel": ["Meta", "Dropbox", "Spotify", "Adroll", "PackLink", "Zoom", "Slack"],
10
  "Andreessen Horowitz": [
11
+ "Airbnb", "Lyft", "Pinterest", "Coinbase", "Robinhood", "Slack"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ],
13
  "Google Ventures": ["Uber", "LendingClub"],
14
  "Greylock": ["Workday", "Palo Alto Networks"],
 
18
  "Emergence Capital Partners": ["Zoom", "Box", "Salesforce"],
19
  "Trinity Ventures": ["New Relic", "Care.com", "TubeMogul"],
20
  "Citi Ventures": ["Square", "Nutanix"],
21
+ "Sequoia": ["Alphabet (Google)", "NVIDIA", "Dropbox", "Airbnb", "Meta"],
22
+ "Y Combinator": ["Dropbox", "Airbnb", "Coinbase", "DoorDash", "Reddit"]
23
+ }
24
+
25
+ # Example market capitalization values (in billions USD)
26
+ market_cap = {
27
+ "Meta": 900,
28
+ "Dropbox": 10,
29
+ "Spotify": 30,
30
+ "Zoom": 20,
31
+ "Slack": 27,
32
+ "Airbnb": 100,
33
+ "Lyft": 4,
34
+ "Pinterest": 14,
35
+ "Coinbase": 70,
36
+ "Robinhood": 10,
37
+ "Uber": 60,
38
+ "LendingClub": 1,
39
+ "Snap": 18,
40
+ "Grubhub": 6,
41
+ "AppDynamics": 1,
42
+ "WeWork": 0.9,
43
+ "Opendoor": 3,
44
+ "Box": 4,
45
+ "Salesforce": 200,
46
+ "Square": 90,
47
+ "Nutanix": 10,
48
+ "Alphabet (Google)": 1500,
49
+ "NVIDIA": 1200
50
  }
51
 
52
+ # Assign default size for missing companies
53
+ default_size = 5
54
+
55
  # Define a color map for the investors
56
  investor_colors = {
57
+ "Accel": "#1f77b4",
58
+ "Andreessen Horowitz": "#ff7f0e",
59
+ "Google Ventures": "#2ca02c",
60
+ "Greylock": "#d62728",
61
+ "Lightspeed Venture Partners": "#9467bd",
62
+ "Benchmark": "#8c564b",
63
+ "Norwest Venture Partners": "#e377c2",
64
+ "Emergence Capital Partners": "#7f7f7f",
65
+ "Trinity Ventures": "#bcbd22",
66
+ "Citi Ventures": "#17becf",
67
+ "Sequoia": "#1b9e77",
68
+ "Y Combinator": "#d95f02"
69
  }
70
 
 
71
  def generate_graph(selected_investors):
72
  if not selected_investors:
73
  selected_investors = list(investors.keys())
74
 
75
  G = nx.Graph()
76
 
77
+ # Add edges and nodes based on selected investors
78
  for investor in selected_investors:
79
  companies = investors[investor]
80
  for company in companies:
 
83
  # Get edge colors
84
  edge_colors = [G[u][v]['color'] for u, v in G.edges]
85
 
86
+ # Set node colors and sizes
87
  node_colors = []
88
+ node_sizes = []
89
  for node in G.nodes:
90
  if node in investor_colors:
91
  node_colors.append(investor_colors[node])
92
+ node_sizes.append(2000) # Fixed size for investors
93
  else:
94
  node_colors.append("#F0E68C") # Khaki for companies
95
+ node_sizes.append(market_cap.get(node, default_size) * 100) # Scale up sizes
96
 
97
  # Create plot
98
  plt.figure(figsize=(18, 18))
 
100
  nx.draw(
101
  G, pos,
102
  with_labels=True,
103
+ node_size=node_sizes,
104
  node_color=node_colors,
105
  font_size=10,
106
  font_weight="bold",
 
134
  ),
135
  outputs=gr.Image(type="pil", label="Venture Network Graph"),
136
  title="Venture Networks Visualization",
137
+ description="Select investors to visualize their investments in various companies. The graph shows connections between investors and the companies they've invested in. Node sizes represent market capitalization.",
138
  flagging_mode="never"
139
  )
140