[ https://issues.apache.org/jira/browse/FLINK-1815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15349585#comment-15349585 ]
Faye Beligianni edited comment on FLINK-1815 at 6/25/16 10:15 AM: ------------------------------------------------------------------ I faced the following problem when I try to test the scala {{fromAdjacencyListFile}} method. The {{fromAdjacencyListFile}} scala method is actually a wrapper of the corresponding java code. In the scala test method, I create a temporary file which represents the Adjacency List formatted text file,like this: {code:java} val adjFileContent = "0-Node0\t1-0.1,4-0.2,5-0.3\n" + "1-Node1\t2-0.3\n" + "2-Node2 3-0.3\n" + "3-Node3 \n" + "4-Node4\n" + "5-Node5 6-0.7\n" + "6-Node6 3-0.2\n" + "7-Node7 4-0.1\n" + "8-Node8 0-0.2\n" val adjFileSplit = createTempFile(adjFileContent) {code} Just for clarification, in the "0-Node0\t1-0.1,4-0.2,5-0.3\n" line of a Adjacency list formatted text file: srcvertex-id : 0 srcVertex-value : Node0 neighbours : 1,4,5 , with 0.1,0.2,0.3 being the corresponding edge values for each edge between the srcVertex and its neighbours. When I read the file and split each line of the file, in order to create the graph, I noticed that I can split the srcVertex from its neighbours, when there is a "\t" character, but not when I have just a whitespace character (" "). I didn't faced this problem in the java tests. I use the split method in order to split the lines in the specified delimiters. {code:java} line.split("\\s+") {code} Any suggestions on how to handle this? was (Author: fobeligi): I faced the following problem when I try to test the scala {{fromAdjacencyListFile}} method. The {{fromAdjacencyListFile}} scala method is actually a wrapper of the corresponding java code. In the scala test method, I create a temporary file which represents the Adjacency List formatted text file,like this: {code:scala} val adjFileContent = "0-Node0\t1-0.1,4-0.2,5-0.3\n" + "1-Node1\t2-0.3\n" + "2-Node2 3-0.3\n" + "3-Node3 \n" + "4-Node4\n" + "5-Node5 6-0.7\n" + "6-Node6 3-0.2\n" + "7-Node7 4-0.1\n" + "8-Node8 0-0.2\n" val adjFileSplit = createTempFile(adjFileContent) {code} Just for clarification, in the "0-Node0\t1-0.1,4-0.2,5-0.3\n" line of a Adjacency list formatted text file: srcvertex-id : 0 srcVertex-value : Node0 neighbours : 1,4,5 , with 0.1,0.2,0.3 being the corresponding edge values for each edge between the srcVertex and its neighbours. When I read the file and split each line of the file, in order to create the graph, I noticed that I can split the srcVertex from its neighbours, when there is a "\t" character, but not when I have just a whitespace character (" "). I didn't faced this problem in the java tests. I use the split method in order to split the lines in the specified delimiters. {code:java} line.split("\\s+") {code} Any suggestions on how to handle this? > Add methods to read and write a Graph as adjacency list > ------------------------------------------------------- > > Key: FLINK-1815 > URL: https://issues.apache.org/jira/browse/FLINK-1815 > Project: Flink > Issue Type: New Feature > Components: Gelly > Affects Versions: 0.9 > Reporter: Vasia Kalavri > Assignee: Faye Beligianni > Priority: Minor > > It would be nice to add utility methods to read a graph from an Adjacency > list format and also write a graph in such a format. > The simple case would be to read a graph with no vertex or edge values, where > we would need to define (a) a line delimiter, (b) a delimiter to separate > vertices from neighbor list and (c) and a delimiter to separate the neighbors. > For example, "1 2,3,4\n2 1,3" would give vertex 1 with neighbors 2, 3 and 4 > and vertex 2 with neighbors 1 and 3. > If we have vertex values and/or edge values, we also need to have a way to > separate IDs from values. For example, we could have "1 0.1 2 0.5, 3 0.2" to > define a vertex 1 with value 0.1, edge (1, 2) with weight 0.5 and edge (1, 3) > with weight 0.2. -- This message was sent by Atlassian JIRA (v6.3.4#6332)