Java

Han_V
391 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Welcome!

Graphs, graphs, graphs. Let's start from the very beginning. We need to store a graph somehow. We will talk about 3 main ways to store a graph later, for now imagine you only have the knowledge you currently have and try to hack your way to victory!

Hands-on Demo

Facebook has your social graph. Why don't you hack your own?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.yourself;
import java.util.List;
public class Graph {
public static class Edge {
public int from;
public int to;
public Edge(int from, int to) {
this.from = from;
this.to = to;
}
}
/*
n - number of nodes in the graph
edges - contains edges of the graph of form {from: 0, to: 4}
note that node indices in this case are zero-based
*/
public Graph(int n, List<Edge> edges) {
// Initialize your graph here
}
public boolean hasEdgeInBetween(int from, int to) {
// answer the query here
return false;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Check out the markdown file welcome.md to see how this exercise is injected into the template.

Template Resources

markdowns/welcome.md What you are reading here is generated by this file. Tech.io uses the Markdown syntax to render text, media and to inject programming exercises.

java-project A simple Java + Maven + JUnit project dedicated to run the programming exercise above. A project relies on a Docker image to run. You can find images on the Docker Hub or you can even build your own.

techio.yml This mandatory file describes both the table of content and the programming project(s). The file path should not be changed.

Visual and Interactive Content

Tech.io provides all the tools to embed visual and interactive content like a Web app or a Unix terminal within your contribution. Please refer to the documentation to learn more about the viewer integrations.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content