Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VertexEdgeCount |
|
| 1.0;1 |
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 | /** | |
22 | * Simple immutable structure for storing a final vertex and edge count. | |
23 | */ | |
24 | public class VertexEdgeCount { | |
25 | /** Immutable vertices */ | |
26 | private final long vertexCount; | |
27 | /** Immutable edges */ | |
28 | private final long edgeCount; | |
29 | ||
30 | /** | |
31 | * Default constructor. | |
32 | */ | |
33 | 218 | public VertexEdgeCount() { |
34 | 218 | vertexCount = 0; |
35 | 218 | edgeCount = 0; |
36 | 218 | } |
37 | ||
38 | /** | |
39 | * Constructor with initial values. | |
40 | * | |
41 | * @param vertexCount Final number of vertices. | |
42 | * @param edgeCount Final number of edges. | |
43 | */ | |
44 | 436 | public VertexEdgeCount(long vertexCount, long edgeCount) { |
45 | 436 | this.vertexCount = vertexCount; |
46 | 436 | this.edgeCount = edgeCount; |
47 | 436 | } |
48 | ||
49 | public long getVertexCount() { | |
50 | 654 | return vertexCount; |
51 | } | |
52 | ||
53 | public long getEdgeCount() { | |
54 | 654 | return edgeCount; |
55 | } | |
56 | ||
57 | /** | |
58 | * Increment the both the vertex edge count with a {@link VertexEdgeCount}. | |
59 | * | |
60 | * @param vertexEdgeCount add both the vertices and edges of this object. | |
61 | * @return New immutable object with the new vertex and edge counts. | |
62 | */ | |
63 | public VertexEdgeCount incrVertexEdgeCount( | |
64 | VertexEdgeCount vertexEdgeCount) { | |
65 | 24 | return new VertexEdgeCount( |
66 | vertexCount + vertexEdgeCount.getVertexCount(), | |
67 | edgeCount + vertexEdgeCount.getEdgeCount()); | |
68 | } | |
69 | ||
70 | /** | |
71 | * Increment the both the vertex edge count with primitives. | |
72 | * | |
73 | * @param vertexCount Add this many vertices. | |
74 | * @param edgeCount Add this many edges. | |
75 | * @return New immutable object with the new vertex and edge counts. | |
76 | */ | |
77 | public VertexEdgeCount incrVertexEdgeCount( | |
78 | long vertexCount, long edgeCount) { | |
79 | 194 | return new VertexEdgeCount( |
80 | this.vertexCount + vertexCount, | |
81 | this.edgeCount + edgeCount); | |
82 | } | |
83 | ||
84 | @Override | |
85 | public String toString() { | |
86 | 48 | return "(v=" + getVertexCount() + ", e=" + getEdgeCount() + ")"; |
87 | } | |
88 | } |