We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Racso • 5 years ago

Hi everyone! I just saw a small English flag in the corner and discovered that Playgrounds can now be translated! I'm happily surprised with that, as the feature wasn't a priority at the moment when I spoke with the Tech.io team. I guess things are evolving quite fast! Soon, you'll find my playgrounds in Spanish, too! // Hola a todos. Acabo de ver una banderita inglesa en la esquina, y descubrí que ahora los playgrounds se pueden traducir. Fue una grata sorpresa, ya que las traducciones no eran una prioridad hace un tiempo, cuando hablé con el equipo de Tech.io. ¡Supongo que las cosas están evolucionando bastante rápido! En fin, pronto encontrarán mis playgrounds traducidos al español :)

Jerome Cance • 5 years ago

Yes we released translation the last week. Don't hesitate to contact me if you have any trouble with it.

Racso • 5 years ago

Thanks, Jerome Cance . Indeed, I'm having some trouble with the translation. I opened a topic in the forums about it :)

Discoordination • 5 years ago

aha parce! puedo improbar a mi castellano al mismo tiempo mi codigo ! Que guay

AndreaZanin • 5 years ago

Bravo! Great introduction to graphs. Are you planning on doing a follow up playground on something more hands-on?

Racso • 5 years ago

Thanks :) Well, yes, I want to make more playgrounds about graph theory, some of them with complete programming exercises. The thing is that learning graph theory is easy on paper (algorithms such as Dijkstra, Prim or Kruskal are surprisingly simple to understand!), but it's difficult to apply in programs for beginners. I'm trying to keep the playgrounds as simple as possible, but yes, I'd like to make some cool, advance problems for people to solve.

Did you have any ideas when you mentioned "something more hands-on"?

Oliver Reischl • 3 years ago
#fix me: for the given graph, return: maximum grade of a node

The term "grade of a node" wasn't mentioned in the course so far, i guess "degree" was meant...? This is confusing for beginners.

bitome • 7 months ago

4 1 True
[[1, 3], [1, 4], [4, 5], [1, 3], [3, 2], [5, 2], [5, 5], [3, 4]]

3 0 True
[[1, 2], [3, 1], [2, 1], [3, 2]]

2 3 False
[[1, 1], [2, 2], [3, 3], [3, 3]]

for the 3 test cases, these are the outputs and it failed on test 3, i don't know why

GreyWolf0628 • 1 year ago

It would be helpful if we could see the tests...

Steven69420 • 2 years ago

"For example, you like someone and they don't like you back".......ouch, stop stalking me

mrunmoy • 4 years ago

Awesome tutorial. Not a python programmer, tried it but it doesn't pass the test cases.

def get_graph_info(adj_list):
# adj_list is the adjacency list of a graph. It's a list of lists, with each element being the two nodes connected by an edge.
# For example, if adj_list=[[0,1],[2,3],[4,3]], we have three edges, one connecting nodes 0 and 1, another one connecting nodes 2 and 3 and a third one connecting nodes 4 and 3.

loop_count = 0
parallel_edges = False
max_degree = 0
all_nodes = dict()
adj_list_set = set()

for item in adj_list:
adj_list_set.add((item[0], item[1]))
all_nodes[item[0]] = item[0]
all_nodes[item[1]] = item[1]
if parallel_edges is False:
if item[0] != item[1]:
if [item[1], item[0]] in adj_list:
parallel_edges = True

for node in all_nodes:
# count parallel edges
if (node, node) in adj_list_set:
loop_count += 1
lst = [item for item in adj_list_set if node in item]
cur_degree = len(lst) + 1
print("degree of node {} is {}".format(node, cur_degree))
lst = [item for item in adj_list_set if node in item]
cur_degree = len(lst)
print("degree of node {} is {}".format(node, cur_degree))
if max_degree < cur_degree:
max_degree = cur_degree

return max_degree, loop_count, parallel_edges # fix me: for the given graph, return: maximum grade of a node, number of loops, boolean representing if there are parallel edges.

davidshq • 5 years ago

Thanks for the intro to graph theory. Hoping you will follow it up with additional lessons?

Racso • 5 years ago

Thank you for reading! Yes, I'm planning to do a complete series on graph theory :). In fact, this wasn't my first playground, but one on Dijkstra's Algorithm: https://tech.io/playgrounds....