Let S be a semigroup with 0 and R be a ring with 1. We extend the definition of the zero-divisor graphs of commutative semigroups to not necessarily commutative semigroups. We define an annihilating-ideal graph of a ring as a special type of zero-divisor graph of a semigroup. We introduce two ways to define the zero-divisor graphs of semigroups. The first definition gives a directed graph

(S), and the other definition yields an undirected graph

(S). It is shown that

(S) is not necessarily connected, but

(S) is always connected and diam

. For a ring R define a directed graph

to be equal to

, where

is a semigroup consisting of all products of two one-sided ideals of R, and define an undirected graph

to be equal to

. We show that R is an Artinian (resp., Noetherian) ring if and only if

has DCC (resp., ACC) on some special subset of its vertices. Also, it is shown that

is a complete graph if and only if either

is a direct product of two division rings, or R is a local ring with maximal ideal m such that

. Finally, we investigate the diameter and the girth of square matrix rings over commutative rings

where

.