
assovary-examples_2.10.4.0.0.source-code.RandomWalkJava Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 Twitter, Inc.
*
* Licensed 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.
*/
/**
* The Java version of the RandomWalk example.
*/
import com.google.common.base.Functions;
import com.google.common.collect.Ordering;
import com.twitter.cassovary.graph.*;
import com.twitter.cassovary.graph.GraphUtils.RandomWalkParams;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import scala.Tuple2;
import scala.collection.JavaConverters$;
import java.util.List;
import java.util.Map;
public class RandomWalkJava {
public static void main(String[] args) {
int numNodes = 3;
if (args.length > 0) numNodes = Integer.parseInt(args[0]);
System.out.printf("Generating a random graph with %d nodes...\n", numNodes);
DirectedGraph graph = TestGraphs.generateRandomGraph(numNodes,
TestGraphs.getProbEdgeRandomDirected(numNodes, Math.min(10, numNodes)),
StoredGraphDir.BothInOut());
System.out.printf("Generated a random directed graph with %s nodes and %s edges.\n", graph.nodeCount(),
graph.edgeCount());
// Generate walk parameters
long numSteps = 1000 * 1000;
final scala.Option
© 2015 - 2025 Weber Informatics LLC | Privacy Policy