Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,246 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41 KB
docs/assets/themes/zeppelin/img/screenshots/display_network_flatten.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,8 @@ public static enum Type { | |
TABLE, | ||
IMG, | ||
SVG, | ||
NULL | ||
NULL, | ||
NETWORK | ||
} | ||
|
||
Code code; | ||
|
76 changes: 76 additions & 0 deletions
76
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/graph/GraphEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.zeppelin.interpreter.graph; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* The base network entity | ||
* | ||
*/ | ||
public abstract class GraphEntity { | ||
|
||
private long id; | ||
|
||
/** | ||
* The data of the entity | ||
* | ||
*/ | ||
private Map<String, Object> data; | ||
|
||
/** | ||
* The primary type of the entity | ||
*/ | ||
private String label; | ||
|
||
//private String color; | ||
|
||
public GraphEntity() {} | ||
|
||
public GraphEntity(long id, Map<String, Object> data, String label) { | ||
super(); | ||
this.setId(id); | ||
this.setData(data); | ||
this.setLabel(label); | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public Map<String, Object> getData() { | ||
return data; | ||
} | ||
|
||
public void setData(Map<String, Object> data) { | ||
this.data = data; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
} |
120 changes: 120 additions & 0 deletions
120
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/graph/GraphResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.zeppelin.interpreter.graph; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.apache.zeppelin.interpreter.InterpreterResult; | ||
|
||
import com.google.gson.Gson; | ||
|
||
/** | ||
* The intepreter result template for Networks | ||
* | ||
*/ | ||
public class GraphResult extends InterpreterResult { | ||
|
||
/** | ||
* The Graph structure parsed from the front-end | ||
* | ||
*/ | ||
public static class Graph { | ||
private Collection<Node> nodes; | ||
|
||
private Collection<Relationship> edges; | ||
|
||
/** | ||
* The node types in the whole graph, and the related colors | ||
* | ||
*/ | ||
private Map<String, String> labels; | ||
|
||
/** | ||
* The relationship types in the whole graph | ||
* | ||
*/ | ||
private Set<String> types; | ||
|
||
/** | ||
* Is a directed graph | ||
*/ | ||
private boolean directed; | ||
|
||
public Graph() {} | ||
|
||
public Graph(Collection<Node> nodes, Collection<Relationship> edges, | ||
Map<String, String> labels, Set<String> types, boolean directed) { | ||
super(); | ||
this.setNodes(nodes); | ||
this.setEdges(edges); | ||
this.setLabels(labels); | ||
this.setTypes(types); | ||
this.setDirected(directed); | ||
} | ||
|
||
public Collection<Node> getNodes() { | ||
return nodes; | ||
} | ||
|
||
public void setNodes(Collection<Node> nodes) { | ||
this.nodes = nodes; | ||
} | ||
|
||
public Collection<Relationship> getEdges() { | ||
return edges; | ||
} | ||
|
||
public void setEdges(Collection<Relationship> edges) { | ||
this.edges = edges; | ||
} | ||
|
||
public Map<String, String> getLabels() { | ||
return labels; | ||
} | ||
|
||
public void setLabels(Map<String, String> labels) { | ||
this.labels = labels; | ||
} | ||
|
||
public Set<String> getTypes() { | ||
return types; | ||
} | ||
|
||
public void setTypes(Set<String> types) { | ||
this.types = types; | ||
} | ||
|
||
public boolean isDirected() { | ||
return directed; | ||
} | ||
|
||
public void setDirected(boolean directed) { | ||
this.directed = directed; | ||
} | ||
|
||
} | ||
|
||
private static final Gson gson = new Gson(); | ||
|
||
public GraphResult(Code code, Graph graphObject) { | ||
super(code, Type.NETWORK, gson.toJson(graphObject)); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/graph/GraphUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.zeppelin.interpreter.graph; | ||
|
||
/** | ||
* An utiliy class for networks | ||
* | ||
*/ | ||
public class GraphUtils { | ||
private GraphUtils() {} | ||
|
||
private static final String[] LETTERS = "0123456789ABCDEF".split(""); | ||
|
||
public static final String COLOR_GREY = "#D3D3D3"; | ||
|
||
public static String getRandomColor() { | ||
char[] color = new char[7]; | ||
color[0] = '#'; | ||
for (int i = 1; i < color.length; i++) { | ||
color[i] = LETTERS[(int) Math.floor(Math.random() * 16)].charAt(0); | ||
} | ||
return new String(color); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/graph/Node.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.zeppelin.interpreter.graph; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* The Zeppelin Node Entity | ||
* | ||
*/ | ||
public class Node extends GraphEntity { | ||
|
||
/** | ||
* The labels (types) attached to a node | ||
*/ | ||
private Set<String> labels; | ||
|
||
public Node() {} | ||
|
||
|
||
public Node(long id, Map<String, Object> data, Set<String> labels) { | ||
super(id, data, labels.iterator().next()); | ||
} | ||
|
||
public Set<String> getLabels() { | ||
return labels; | ||
} | ||
|
||
public void setLabels(Set<String> labels) { | ||
this.labels = labels; | ||
} | ||
|
||
} |
Oops, something went wrong.