MATSIM
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
org.matsim.run.NetworkCleaner Class Reference

Public Member Functions

void run (final String inputNetworkFile, final String outputNetworkFile)
 
void run (final String[] args)
 

Static Public Member Functions

static void main (String[] args)
 

Private Member Functions

void printUsage ()
 

Detailed Description

Reads a network from file and "cleans" it to ensure the network is suited for simulation. Currently, it is ensured that every link can be reached by every other link.

Author
mrieser

Definition at line 39 of file NetworkCleaner.java.

Member Function Documentation

◆ printUsage()

void org.matsim.run.NetworkCleaner.printUsage ( )
private

Definition at line 41 of file NetworkCleaner.java.

Referenced by org.matsim.run.NetworkCleaner.run().

41  {
42  System.out.println();
43  System.out.println("NetworkCleaner");
44  System.out.println("Reads a network-file and \"cleans\" it. Currently, it performs the following");
45  System.out.println("steps to ensure a network is suited for simulation:");
46  System.out.println(" - ensure every link can be reached by every other link. It looks for the");
47  System.out.println(" biggest cluster of connected nodes and links and removes all other elements.");
48  System.out.println();
49  System.out.println("usage: NetworkCleaner [OPTIONS] input-network-file output-network-file");
50  System.out.println();
51  System.out.println("Options:");
52  System.out.println("-h, --help: Displays this message.");
53  System.out.println();
54  System.out.println("----------------");
55  System.out.println("2008, matsim.org");
56  System.out.println();
57  }

◆ run() [1/2]

void org.matsim.run.NetworkCleaner.run ( final String  inputNetworkFile,
final String  outputNetworkFile 
)

Runs the network cleaning algorithms over the network read in from inputNetworkFile and writes the resulting ("cleaned") network to the specified file.

Parameters
inputNetworkFilefilename of the network to be handled
outputNetworkFilefilename where to write the cleaned network to

Definition at line 65 of file NetworkCleaner.java.

References org.matsim.core.config.ConfigUtils.createConfig(), org.matsim.core.scenario.ScenarioUtils.createScenario(), org.matsim.api.core.v01.Scenario.getNetwork(), org.matsim.core.network.algorithms.NetworkCleaner.run(), and org.matsim.core.network.io.NetworkWriter.write().

Referenced by org.matsim.run.NetworkCleaner.main(), and org.matsim.run.NetworkCleaner.run().

65  {
66  final Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
67  final Network network = scenario.getNetwork();
68  new MatsimNetworkReader(scenario.getNetwork()).readFile(inputNetworkFile);
69 
71 
72  new NetworkWriter(network).write(outputNetworkFile);
73  }
Here is the call graph for this function:

◆ run() [2/2]

void org.matsim.run.NetworkCleaner.run ( final String []  args)

Runs the network cleaning algorithms over the network read in from the argument list, and writing the resulting network out to a file again

Parameters
argsargs[0] filename of the network to be handled, args[1] filename where to write the cleaned network to

Definition at line 81 of file NetworkCleaner.java.

References org.matsim.core.utils.misc.ArgumentParser.iterator(), org.matsim.run.NetworkCleaner.printUsage(), and org.matsim.run.NetworkCleaner.run().

81  {
82  if (args.length == 0) {
83  System.out.println("Too few arguments.");
84  printUsage();
85  System.exit(1);
86  }
87  Iterator<String> argIter = new ArgumentParser(args).iterator();
88  String arg = argIter.next();
89  if (arg.equals("-h") || arg.equals("--help")) {
90  printUsage();
91  System.exit(0);
92  } else {
93  String inputFile = arg;
94  if (!argIter.hasNext()) {
95  System.out.println("Too few arguments.");
96  printUsage();
97  System.exit(1);
98  }
99  String outputFile = argIter.next();
100  if (argIter.hasNext()) {
101  System.out.println("Too many arguments.");
102  printUsage();
103  System.exit(1);
104  }
105  run(inputFile, outputFile);
106  }
107  }
void run(final String inputNetworkFile, final String outputNetworkFile)
Here is the call graph for this function:

◆ main()

static void org.matsim.run.NetworkCleaner.main ( String []  args)
static

Definition at line 109 of file NetworkCleaner.java.

References org.matsim.run.NetworkCleaner.run().

109  {
110  new NetworkCleaner().run(args);
111  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: