1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.giraph.graph;
20
21 import org.apache.hadoop.mapreduce.Mapper;
22
23 /**
24 * Immutable global state of the graph.
25 */
26 public class GraphState {
27 /** Graph-wide superstep */
28 private final long superstep;
29 /** Graph-wide number of vertices */
30 private final long numVertices;
31 /** Graph-wide number of edges */
32 private final long numEdges;
33 /** Graph-wide map context */
34 private final Mapper<?, ?, ?, ?>.Context context;
35
36 /**
37 * Constructor
38 *
39 * @param superstep Current superstep
40 * @param numVertices Current graph-wide vertices
41 * @param numEdges Current graph-wide edges
42 * @param context Context
43 *
44 */
45 public GraphState(long superstep, long numVertices, long numEdges,
46 Mapper<?, ?, ?, ?>.Context context) {
47 this.superstep = superstep;
48 this.numVertices = numVertices;
49 this.numEdges = numEdges;
50 this.context = context;
51 }
52
53 public long getSuperstep() {
54 return superstep;
55 }
56
57 public long getTotalNumVertices() {
58 return numVertices;
59 }
60
61 public long getTotalNumEdges() {
62 return numEdges;
63 }
64
65 public Mapper.Context getContext() {
66 return context;
67 }
68
69 @Override
70 public String toString() {
71 return "(superstep=" + superstep + ",numVertices=" + numVertices + "," +
72 "numEdges=" + numEdges + ",context=" + context + ")";
73 }
74 }