Code for Random Graph Generation G(n,p) 1

Code for Random Graph Generation G(n,p)
Following is the Java code for generating a Random Graph G(n, p) where ‘n’ is the number of nodes/ vertices in the graph and ‘p’ is the probability that any edge will form or not. The code makes use of JUNG API for graph visualization and creation. More About JUNG… Java import java.awt.Dimension; import javax.swing.JFrame; ...

ConcurrentHashMap 1

ConcurrentHashMap
Javadoc says… “A hash table except supporting full concurrency of retrievals and adjustable expected concurrency for updates. This class obeys the same functional specification as Hashtable, and includes versions of methods corresponding to each method of Hashtable. However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any ...

Matlab code to create k-connected Harary Graph 4

Matlab code to create k-connected Harary Graph
The following is a MATLAB script to create a k-connected Harary Graph of n-nodes. Clearly the inputs required are n (no of nodes) and k (degree of each node). Also, while the code is a MATLAB script the basic technique to generate the adjacency matrix of the graph can be easily adopted to other languages ...

StringBuffer vs StringBuilder

  According to javadoc, StringBuilder is designed as a replacement for StringBuffer in single-threaded usage. Their key differences in simple term: StringBuffer is designed to be thread-safe and all public methods in StringBuffer are synchronized. StringBuilder does not handle thread-safety issue and none of its methods is synchronized. StringBuilder has better performance than StringBuffer under ...

executeQuery, executeUpdate and execute

executeQuery public ResultSet executeQuery() throws SQLException Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query. Returns: a ResultSet object that contains the data produced by the query; never null Throws: SQLException – if a database access error occurs or the SQL statement does not return a ResultSet ...

TreeMap

The TreeMap class implements the Map interface by using a tree. A TreeMap provides an efficient means of storing key/value pairs in sorted order, and allows rapid retrieval. You should note that, unlike a hash map, a tree map guarantees that its elements will be sorted in ascending key order. The TreeMap class supports four ...

Why use Generics in Java?

Generics add a way to specify concrete types to general purpose classes and methods that operated on Object before.   Code that uses generics has many benefits over non-generic code: 1. Stronger type checks at compile time(Compile-time type safety). A Java compiler applies strong type checking to generic code and issues errors if the code violates ...

What is Object-Relational mapping (ORM) framework? 1

Object-relational mapping (ORM, O/RM or O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language. There are both free and commercial packages available that perform ...

UnsupportedClassVersionError

Description : java.lang.UnsupportedClassVersionError:Bad version number in .class file  Cause: When code was compiled on a new version of Java and user is trying to run it on the older version of Java Possible Solution :  Make sure that both the versions are same.  

Understanding Hashcodes

Understanding Hashcodes
Imagine a set of buckets lined up on the floor. Someone hands you a piece of paper with a name on it. You take the name and calculate an integer code from it by using A is 1, B is 2, and so on, and adding the numeric values of all the letters in the ...